VoteIT

  • Nyheter
  • Dokumentation
  • Medlemmar
  • Kod
Star
ASSET MANAGEMENT

Creating a resource from template

Hugo Pipes allows the creation of a resource from an asset file using Go Template.

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.

// 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 }}
  • Om
    • Om VoteIT
    • VoteIT och GDPR
    • Vad är VoteIT
    • VoteIT Funktioner
    • Fördelar med VoteIT
    • Licens
  • Kom Igång
    • Överblick
    • Snabbstart
    • Installera VoteIT
    • Grundläggande Användning
    • Konfiguration
  • Administration
  • Innehåll
  • Mallar
  • Funktioner
  • Variabler
  • Användarguider
  • Problemlösning
  • Verktyg
  • Drift och Utrullning
  • Bidra
  • about
    • Bylaws
    • History
  • pipes
    • Hugo Pipes Overview
    • Hugo Pipes Introduction
    • SASS / SCSS
    • PostCSS
    • Asset minification
    • Asset bundling
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
“Creating a resource from template” was last updated: July 14, 2018
Improve this page
By the VoteIT Authors
VoteIT Logo
  • File an Issue
  • @VoteIT
  • @robin_betahaus
  • @andershultman
 
 

VoteIT Sponsors

Logo for VoteIT
Logo for Betahaus
Logo for Datatrion AB
 

The VoteIT logos are copyright © VoteIT 2011–2020.

  • Nyheter
  • Dokumentation
  • Medlemmar
  • Kod
  • Om
  • Kom Igång
  • Administration
  • Innehåll
  • Mallar
  • Funktioner
  • Variabler
  • Användarguider
  • Problemlösning
  • Verktyg
  • Drift och Utrullning
  • Bidra
  • about
  • pipes