GAS - 将变量传递给HTML输出,然后传递给Scriptlet [英] GAS - Passing variable to HTML output and then into a Scriptlet
问题描述
Code.gs
函数doPost(e){
...
template.data + = getCustomerData +< br>;
}
返回template.evaluate()。setSandboxMode(HtmlService.SandboxMode.IFRAME);
index.html
...
<?= data?>>
显示的代码显示正确的值。但是,它不会将< br>
转换为html。我不确定为什么它不起作用,因为 template.evaluate()
应该返回一个HtmlOutput对象。
默认情况下,字符串已经过清理,将特殊字符转换为其HTML编码的等价物(如<正在& lt;)。
在输出HTML时,您必须使用<?!=来避免消毒数据。
$ b
<?!= data? >
查看有关标准&强制打印scriptlets:
https://developers.google .com / apps-script / guides / html / templates#standard_scriptlets
Code.gs
function doPost(e) {
...
template.data += getCustomerData + "<br>";
}
return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
index.html
...
<?= data ?>
The code shown does display the correct values. However, it doesn't translate <br>
into html. I'm not sure why it isn't working since template.evaluate()
is supposed to return an HtmlOutput object.
By default the strings are sanitized, converting special characters to their HTML encoded equivalents (such as < becoming <).
When outputting HTML you must use <?!= to avoid sanitizing the data.
<?!= data ?>
See the details on standard & force-printing scriptlets here: https://developers.google.com/apps-script/guides/html/templates#standard_scriptlets
这篇关于GAS - 将变量传递给HTML输出,然后传递给Scriptlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!