如何在Google Apps脚本中将css连接到html [英] How to connect css to html in Google Apps Scripts
问题描述
我正在尝试制作我的第一个Google应用。我有我的HTML文档,其中包含 HTML服务:最佳实践。
< html>
< head>
< base target =_ top>
<?!= include('stylesheet')?>
< / head>
< body>
...
< / body>
我的code.gs文件如下:
函数doGet(){
return HtmlService.createTemplateFromFile('BooksTS2.html')
.evaluate();
}
我的样式表被命名为stylesheet.html,并且出于测试目的非常简单:
< style>
p {color:green;}
< / style>
但是,当我运行它时,我收到以下错误消息:ReferenceError:include未定义。 / p>在这个例子中,他们创建了可重用的函数 include(),您需要将其添加到您的 code.gs 文件:
函数include(文件名){
return HtmlService.createHtmlOutputFromFile (文件名)
.getContent();
}
您可以随时使用打印 scriptlet 直接在您的html文件中显示,如下所示:
< HTML>
< head>
< base target =_ top>
<?!= HtmlService.createHtmlOutputFromFile('stylesheet')。getContent(); ?>
< / head>
< body>
...
< / body>
< / html>
I'm trying to make my first Google App. I have my HTML doc which has the include statement as outlined on HTML Service: Best Practices.
<html>
<head>
<base target="_top">
<?!= include('stylesheet') ?>
</head>
<body>
...
</body>
My code.gs file is as follows:
function doGet() {
return HtmlService.createTemplateFromFile('BooksTS2.html')
.evaluate();
}
My style sheet is named stylesheet.html, and for testing purposes is really simple:
<style>
p {color: green;}
</style>
But when I run it I get this error message: ReferenceError: "include" is not defined.
In the example they created the reusable function include(), you need to add it in your code.gs file:
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
You can always use the printing scriptlet directly in your html file like this:
<html>
<head>
<base target="_top">
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
</head>
<body>
...
</body>
</html>
这篇关于如何在Google Apps脚本中将css连接到html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!