#author("2020-02-29T19:10:44+09:00","default:haikikyou","haikikyou")
#author("2020-02-29T19:11:00+09:00","default:haikikyou","haikikyou")
[[Go]]

#contents

* Go Template [#z49b334e]

- テンプレート機能。
- htmlなどのテキストに変数などの可変値や制御構造を埋め込み、動的な出力が可能。~
&code(){{{ . }}};や&code(){{{ .var }}};のような記述をする。PythonのDjangoテンプレートにあるフィルタのような機能(pipelines)もある。
#geshi{{{
I am {{.name}}. I'm from {{.from}}.
length of string "hello" is {{.msg | len}} 
}}}
- 汎用的なtextとHTMLドキュメント用のhtmlパッケージがある。
-- https://golang.org/pkg/text/template/
-- https://golang.org/pkg/html/template/

* テキストの出力 [#re8ea172]
* テキストとスペース [#re8ea172]

- {{- は前方に位置するスペースを削除する。
- -}} は後方に続くスペースを削除する。

#geshi(go){{{
{{10 -}} ** {{- 20}}
}}}

上記の出力は以下のとおり。

#geshi{{{
10**20
}}}
* 参考リンク [#z06b9e4c]

- https://golang.org/pkg/text/template/
- https://golang.org/pkg/html/template/

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP