LoginSignup
0

More than 5 years have passed since last update.

メモ html.template

Last updated at Posted at 2017-09-28

文字列が入っている時だけ表示する

{{if .ReturnUrl}}
<a class="ui button" href="{{.ReturnUrl}}">戻る</a>
{{else}}
戻れません
{{end}}

コメント

{{/* ここにかく */}}

エスケープさせない

コード

body := "<b>test</b>"
err := templ.Execute(w, map[string]interface{}{
    "Body": template.HTML(body),
})

テンプレートは他のと変わらない

{{.Body}}

テンプレートを読み込む

templ, err := template.ParseFiles("views/index.html")

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0