whisker.render: Logicless templating

View source: R/whisker.R

whisker.renderR Documentation

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 documentation built on Dec. 5, 2022, 5:22 p.m.