1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/pkg.R 3\docType{package} 4\name{whisker-package} 5\alias{whisker-package} 6\title{{{Mustache for R}}} 7\description{ 8Whisker is a templating engine for R conforming to the Mustache specification. 9Mustache is a logicless templating language, meaning that no programming source 10code can be used in your templates. This may seem very limited, but Mustache is nonetheless 11powerful and has the advantage of being able to be used unaltered in many programming 12languages. For example it make it very easy to write a web application in R using Mustache templates 13and where the browser can template using javascript's "Mustache.js" 14} 15\details{ 16Mustache (and therefore \code{whisker}) takes a simple but different approach to templating compared to 17most templating engines. Most templating libraries for example \code{Sweave} and \code{brew} allow the user 18to mix programming code and text throughout the template. This is powerful, but ties a template directly 19to a programming language. Furthermore that approach makes it difficult to seperate programming code 20from templating code. 21 22Whisker on the other hand, takes a Mustache template and uses the variables of the current environment (or the 23supplied \code{list}) to fill in the variables. 24} 25\examples{ 26template <- 27'Hello {{name}} 28You have just won ${{value}}! 29{{#in_ca}} 30Well, ${{taxed_value}}, after taxes. 31{{/in_ca}}' 32 33data <- list( name = "Chris" 34 , value = 10000 35 , taxed_value = 10000 - (10000 * 0.4) 36 , in_ca = TRUE 37 ) 38 39whisker.render(template, data) 40 41 42 43 44base <- 45'<h2>Names</h2> 46{{#names}} 47 {{> user}} 48{{/names}}' 49 50user <- '<strong>{{name}}</strong>' 51 52names <- list(list(name="Alice"), list(name="Bob")) 53 54whisker.render(base, partials=list(user=user)) 55 56} 57