VoteIT

  • Nyheter
  • Dokumentation
  • Medlemmar
  • Kod
Star
ASSET MANAGEMENT

Creating a resource from a string

Hugo Pipes allows the creation of a resource from a string.

It is possible to create a resource directly from the template using resources.FromString which takes two arguments, the given string and the resource target path.

The following example creates a resource file containing localized variables for every project’s languages.

{{ $string := (printf "var rootURL: '%s'; var apiURL: '%s';" (absURL "/") (.Param "API_URL")) }}
{{ $targetPath := "js/vars.js" }}
{{ $vars := $string | resources.FromString $targetPath }}
{{ $global := resources.Get "js/global.js" | resources.Minify }}

<script type="text/javascript" src="{{ $vars.Permalink }}"></script>
<script type="text/javascript" src="{{ $global.Permalink }}"></script>
  • 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 a string” 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