Google Apps脚本模板化HTML

时间:2018-07-25 23:26:00

标签: google-apps-script

已弃用“ Google Apps脚本模板”。当在下面运行showSidebar代码时,它将在边栏中显示以下内容:

Hello, World! The time is .

=========================

文件:code.gs

function showSidebar() {
   var ui = HtmlService.createHtmlOutputFromFile('index')
  .setTitle('test');

  SpreadsheetApp.getUi().showSidebar(ui);
}

=====================

文件:index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Hello, World! The time is <?= new Date() ?>.
  </body>
</html>

这是Google上有关应用程序脚本模板的文档的链接

https://developers.google.com/apps-script/guides/html/templates

1 个答案:

答案 0 :(得分:2)

否,尚未弃用模板。

必须使用createHtmlOutputFromFile(),而不是使用createHtmlTemplateFromFile(),然后使用evaluate()评估模板才能生成HtmlOutput。

此过程显示在您链接的文档的顶部。