[英]Separating html file in apps script
I have an apps script file where I want to separate my html and css.我有一个应用程序脚本文件,我想在其中分离我的 html 和 css。 Given we can't create .css files in apps script, I have create a file 'mainmenucss.html' and put my css in a style tag, and using the include function (see below) to add that file in, but none of my styling is showing when I do that.
鉴于我们无法在应用程序脚本中创建 .css 文件,我创建了一个文件“mainmenucss.html”并将我的 css 放在样式标记中,并使用包含函数(见下文)添加该文件,但没有当我这样做时,我的造型就会显示出来。
index.html索引.html
<!DOCTYPE html>
<html>
<head>
<?!= include('mainmenucss.html') ?>
</head>
code.gs代码.gs
function doGet(request) {
return HtmlService.createTemplateFromFile('mainmenu')
.evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
mainmenucss.html主菜单.html
<style>
/*-- Text you have "X" emails left --*/
div {
display: block;
}
body {
font: normal 10pt Arial, sans-serif;
}
</style>
How about this modification?这个改装怎么样?
I think that in your script, an error might occur at return HtmlService.createTemplateFromFile(filename).getContent();
我认为在您的脚本中,
return HtmlService.createTemplateFromFile(filename).getContent();
可能会发生错误return HtmlService.createTemplateFromFile(filename).getContent();
. . Because HtmlTemplate has no method of
getContent()
.因为 HtmlTemplate 没有
getContent()
方法。 So how about the following modification?那么下面的修改呢?
return HtmlService.createTemplateFromFile(filename).getContent();
return HtmlService.createTemplateFromFile(filename).evaluate().getContent();
or或者
return HtmlService.createHtmlOutputFromFile(filename).getContent();
mainmenucss.html
?mainmenucss.html
的脚本? If I misunderstood your question and this was not the result you want, I apologize.如果我误解了您的问题并且这不是您想要的结果,我深表歉意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.