mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	
		
			
				
	
	
	
		
			1018 B
		
	
	
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1018 B
		
	
	
	
	
		
			Executable File
		
	
	
	
	
title, linkTitle, description, date, publishdate, lastmod, categories, keywords, menu, weight, sections_weight, draft
| title | linkTitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | sections_weight | draft | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Creating a resource from template | Resource from Template | Hugo Pipes allows the creation of a resource from an asset file using Go Template. | 2018-07-14 | 2018-07-14 | 2018-07-14 | 
  | 
  | 
80 | 80 | 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 target path, 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 }}