Sherlock
Sherlock

Reputation: 5627

Google apps script html template issue

How can I use a function that returns html within a string, inside a html template in google apps script ?

For example, here is my code.gs:

function doGet() {
  return HtmlService.createTemplateFromFile('test').evaluate();
}

function getHtml(){
  return "<b> hello there </b>";
}

and in my html file 'test.html' I have the following:

<html>
 <?= getHtml() ?>
</html>

You will see the result is something like this:

enter image description here

How can I change this so it produces hello there in bold, without showing the tags ?

Many thanks

Upvotes: 0

Views: 1911

Answers (1)

Corey G
Corey G

Reputation: 7858

Use force-printing:

 <?!= getHtml() ?>

as explained here.

Upvotes: 4

Related Questions