diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-10-21 10:22:28 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-10-21 10:22:28 +0200 |
commit | 27aef3f1fbf657137e825f30bb50dda393618a6f (patch) | |
tree | bcc05254f2977e3cc75d7dcb4cbaac5625cf7a1b /docs/content/en/hugo-pipes/resource-from-template.md | |
parent | 39121de4d991bdcf5f202da4d8d81a8ac6c149fc (diff) | |
parent | b9bd35d72e14932fb6588ff62b90cddef0a060fc (diff) |
Merge commit 'b9bd35d72e14932fb6588ff62b90cddef0a060fc' as 'docs'
Diffstat (limited to 'docs/content/en/hugo-pipes/resource-from-template.md')
-rwxr-xr-x | docs/content/en/hugo-pipes/resource-from-template.md | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/content/en/hugo-pipes/resource-from-template.md b/docs/content/en/hugo-pipes/resource-from-template.md new file mode 100755 index 000000000..317630b40 --- /dev/null +++ b/docs/content/en/hugo-pipes/resource-from-template.md @@ -0,0 +1,38 @@ +--- +title: Creating a resource from template +linkTitle: Resource from Template +description: Hugo Pipes allows the creation of a resource from an asset file using Go Template. +date: 2018-07-14 +publishdate: 2018-07-14 +lastmod: 2018-07-14 +categories: [asset management] +keywords: [] +menu: + docs: + parent: "pipes" + weight: 80 +weight: 80 +sections_weight: 80 +draft: false +--- + +In order to use Hugo Pipes function on an asset file containing Go Template magic the function `resources.ExecuteAsTemplate` must be used. + +The function takes three arguments, the resource object, the resource target path and the template context. + +```go-html-template +// assets/sass/template.scss +$backgroundColor: {{ .Param "backgroundColor" }}; +$textColor: {{ .Param "textColor" }}; +body{ + background-color:$backgroundColor; + color: $textColor; +} +// [...] +``` + + +```go-html-template +{{ $sassTemplate := resources.Get "sass/template.scss" }} +{{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS }} +```
\ No newline at end of file |