Content
返回给定资源的内容。
资源类型为 page 时,Resource 对象上的 Content 方法返回 template.HTML,否则返回 string。
He travels the fastest who travels alone.要取得内容:
{{ with resources.Get "quotations/kipling.txt" }}
{{ .Content }} → He travels the fastest who travels alone.
{{ end }}要取得以字节为单位的大小:
{{ with resources.Get "quotations/kipling.txt" }}
{{ .Content | len }} → 42
{{ end }}要创建内联图像:
{{ with resources.Get "images/a.jpg" }}
<img src="data:{{ .MediaType.Type }};base64,{{ .Content | base64Encode }}">
{{ end }}要创建内联 CSS:
{{ with resources.Get "css/style.css" }}
<style>{{ .Content | safeCSS }}</style>
{{ end }}要创建内联 JavaScript:
{{ with resources.Get "js/script.js" }}
<script>{{ .Content | safeJS }}</script>
{{ end }}