How to process scriptlets in my HTML file instead

2019-08-24 13:12发布

问题:

I can't figure it out how I can get the HTML to process the extension/caller (scriptlets) that look like this <?= var data = getData()?>. Here is my script code link.

Please check out my error:

回答1:

From my answer here:

If you have the <?...?> scriptlets in your HTML file when you evaluate with the HTMLService you need to use createTemplateFromFile() otherwise they will be treated as plain text. The createHTMLOutputFromFile() won't work for evaluating the script tags.

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

You should take a look at the HTMLService best practices for async loading.