Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

whisker.render

Logicless templating


Description

Logicless templating

Usage

whisker.render(template, data = parent.frame(), partials = list(),
  debug = FALSE, strict = TRUE)

Arguments

template

character with template text

data

named list or environment with variables that will be used during rendering

partials

named list with partial templates, will be used during template construction

debug

Used for debugging purposes, likely to disappear

strict

logical if TRUE the seperation symbol is a "." otherwise a "$"

Value

character with rendered template

Note

By default whisker applies html escaping on the generated text. To prevent this use {{{variable}}} (triple) in stead of {{variable}}.

Examples

template <- "Hello {{place}}!"
place <- "World"

whisker.render(template)

# to prevent html escaping use triple {{{}}}
template <- 
  "I'm escaped: {{name}}
And I'm not: {{{name}}}"

data <- list( name = '<My Name="Nescio&">')
whisker.render(template, data)
# I'm escaped: &lt;My Name=&quot;Nescio&amp;&quot;&gt;
# And I'm not: <My Name="Nescio&">

whisker

{{mustache}} for R, Logicless Templating

v0.4
GPL-3
Authors
Edwin de Jonge
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.