Learn R Programming

whisker (version 0.4.1)

whisker.render: Logicless templating

Description

Logicless templating

Usage

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

Value

character with rendered template

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 "$"

Examples

Run this code
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 = '')
whisker.render(template, data)
# I'm escaped: <My Name="Nescio&">
# And I'm not: 

Run the code above in your browser using DataLab