包括其他无法使用的内容文件-<?!=?>标签呈现为文本 [英] Including additional content file not working - <?!= ?> tags rendering as text

查看:52
本文介绍了包括其他无法使用的内容文件-<?!=?>标签呈现为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循最佳做法页面的将HTML,CSS和JavaScript分开"部分中的代码.( https://developers.google.com/apps-script/guides/html/best-practices#separate_html_css_and_javascript )

I am following the code in the best practices page's section for "Separate HTML, CSS, and JavaScript" to the dot. (https://developers.google.com/apps-script/guides/html/best-practices#separate_html_css_and_javascript)

但是,该标记不是在包含的页面中呈现CSS/Javascript,而是在页面上显示为文本:

However, instead of rendering the CSS/Javascript within my included pages, the tag is rendered as text on the page:

<?!= include('Stylesheet');?>

<?!= include('Stylesheet'); ?>

此外,我还尝试用直接调用HtmlService代替include函数,但是产生了相同的结果:

Additionally, I also tried replacing the include function with a direct call to HtmlService instead, but yielded the same results:

<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent();?>

<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>

我在这里错过了重要的东西吗?

Am I missing something important here?

谢谢

推荐答案

确保您使用的是 HtmlService.createTemplateFromFile()方法,而不是Code.gs文件中的.createHtmlOutputFromFile()方法-在GAS中使用模板化HTML时常见的错误.从您发布的代码片段看来,这可能是您的问题.此处的完整文档:链接

Make sure you are using HtmlService.createTemplateFromFile() method, and not .createHtmlOutputFromFile() in your Code.gs file - that's a common mistake when working with templated HTML in GAS. From the code snippets you posted it looks like that might be your problem. Full docs here: link

这篇关于包括其他无法使用的内容文件-&lt;?!=?&gt;标签呈现为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆