mirror of https://github.com/gohugoio/hugo
1.0 KiB
Executable File
1.0 KiB
Executable File
title | linkTitle | description | categories | keywords | menu | weight | action | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ExecuteAsTemplate | Resource from template | Creates a resource from a template |
|
|
120 |
|
Usage
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 target path for the created resource, the template context, and the resource object. The target path is used to cache the result.
// assets/sass/template.scss
$backgroundColor: {{ .Param "backgroundColor" }};
$textColor: {{ .Param "textColor" }};
body{
background-color:$backgroundColor;
color: $textColor;
}
// [...]
{{ $sassTemplate := resources.Get "sass/template.scss" }}
{{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | css.Sass }}