createTemplateFromFile
Gasでは通常htmlファイルはテンプレートを読み込む形で書かれますので、
createTemplateFromFileを使っていきます。
ファイル名は index にして変数templateに代入します。
var template = HtmlService.createTemplateFromFile('index');
template.evaluate()
テンプレートを評価しつつ返してくれる template.evaluate() を使います。
return template.evaluate()で返してくれます。
function doGet() { var template = HtmlService.createTemplateFromFile('index'); return template.evaluate(); }
indexファイル作成
まずは簡単なindexファイルを作成してみます。
1)ファイル → 2)新規作成 → 3)HTMLファイル です。

ファイル名を index にします。

[kbk]ok[se] をクリックするとすでに一部が記入されたhtml5画面が現れます。

ファイルの中身に追記します。
<h1>My Task</h1> <ul> <li>Task</li> <li>Task</li> <li>Task</li> </ul>

では、doGetを実行します。
あらかじめ開いてある開発者用のURLを再読み込みします。

このように変更されていれば完了です。
コメント