回答編集履歴
1
コメントを反映
answer
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
詳しくは公式ドキュメントの [HTML Service: Templated HTML -> Pushing variables to templates](https://developers.google.com/apps-script/guides/html/templates#pushing_variables_to_templates) をどうぞ。
|
4
4
|
|
5
|
+
(2019/11/18 コメントの内容をサンプルソースへ反映しました。)
|
6
|
+
|
5
7
|
- test.gs
|
6
8
|
```JavaScript
|
7
9
|
function doGet(e) {
|
@@ -11,6 +13,11 @@
|
|
11
13
|
|
12
14
|
return template.evaluate();
|
13
15
|
}
|
16
|
+
|
17
|
+
//テンプレートからパラメータを引数として受け取る
|
18
|
+
function getData(mydata) {
|
19
|
+
return "getData()の引数は" + mydata + "です。";
|
20
|
+
}
|
14
21
|
```
|
15
22
|
- index.html
|
16
23
|
```HTML
|
@@ -20,7 +27,8 @@
|
|
20
27
|
<base target="_top">
|
21
28
|
</head>
|
22
29
|
<body>
|
30
|
+
<!-- テンプレートで渡されたパラメータをgetData()の引数として渡す -->
|
23
|
-
<?= mydata ?>
|
31
|
+
<?= getData(mydata) ?>
|
24
32
|
</body>
|
25
33
|
</html>
|
26
34
|
```
|