mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
957 B
Executable file
957 B
Executable file
title | linkTitle | description | categories | keywords | menu | weight | signature | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ExecuteAsTemplate | Resource from Template | Creates a resource from a template |
|
|
80 |
|
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.
// 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" . | resources.ToCSS }}