0
votes

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

1

1 Answers

4
votes

Use force-printing:

 <?!= getHtml() ?>

as explained here.