Google apps script html template issue

醉酒当歌 提交于 2021-01-29 20:25:34

问题


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:


Use force-printing:

 <?!= getHtml() ?>

as explained here.



来源:https://stackoverflow.com/questions/14729845/google-apps-script-html-template-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!