VoteIT

  • News
  • Documentation
  • Members
  • In Swedish
  • Code
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 }}
  • About VoteIT
    • Overview
    • Hugo and GDPR
    • What is Hugo
    • Bylaws
    • History
    • Hugo Features
    • The Benefits of Static
    • License
  • Getting Started
    • Get Started Overview
    • Quick Start
    • Install Hugo
    • Basic Usage
    • Directory Structure
    • Configuration
  • VoteIT Modules
  • Content Management
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
    • Hugo Pipes Overview
    • Hugo Pipes Introduction
    • SASS / SCSS
    • PostCSS
    • Asset minification
    • Asset bundling
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute
“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.

  • News
  • Documentation
  • Members
  • In Swedish
  • Code
  • About VoteIT
  • Getting Started
  • VoteIT Modules
  • Content Management
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute