Package whisker. R topics documented: February 20, 2015



Similar documents
Package retrosheet. April 13, 2015

Package sendmailr. February 20, 2015

Package EasyHTMLReport

Package missforest. February 20, 2015

Package xtal. December 29, 2015

Package pesticides. February 20, 2015

Package sjdbc. R topics documented: February 20, 2015

Package empiricalfdr.deseq2

Package ChannelAttribution

Package MBA. February 19, Index 7. Canopy LIDAR data

Package OECD. R topics documented: January 17, Type Package Title Search and Extract Data from the OECD Version 0.2.

Package R4CDISC. September 5, 2015

Package cgdsr. August 27, 2015

Package HadoopStreaming

Package StockChina. January 30, 2016

Package searchconsoler

Package uptimerobot. October 22, 2015

Package wordcloud. R topics documented: February 20, 2015

Package png. February 20, 2015

Package pxr. February 20, 2015

Package dfoptim. July 10, 2016

Package packrat. R topics documented: March 28, Type Package

Package treemap. February 15, 2013

Package pdfetch. R topics documented: July 19, 2015

Package translater. R topics documented: February 20, Type Package

Package TSfame. February 15, 2013

Package decompr. August 17, 2016

Package httprequest. R topics documented: February 20, 2015

Package LexisPlotR. R topics documented: April 4, Type Package

Package Rdsm. February 19, 2015

Package urltools. October 11, 2015

Package tagcloud. R topics documented: July 3, 2015

Package gazepath. April 1, 2015

Package neuralnet. February 20, 2015

Package bigdata. R topics documented: February 19, 2015

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

Introduction to ASP. Are you sick of static HTML pages? Do you want to create dynamic web pages? Do you

Adding Events guide. Hampshire Fire and Rescue Service. Document Author: Richard Firth

Package dsstatsclient

Package benford.analysis

Writing R packages. Tools for Reproducible Research. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Package PRISMA. February 15, 2013

Package COSINE. February 19, 2015

Package EstCRM. July 13, 2015

Package fimport. February 19, 2015

Developing ASP.NET MVC 4 Web Applications MOC 20486

Package schoolmath. R topics documented: February 20, Type Package

Package DCG. R topics documented: June 8, Type Package

Package obs.agree. February 20, 2015

Package RIGHT. March 30, 2015

Package globe. August 29, 2016

Package CIFsmry. July 10, Index 6

Package bigrf. February 19, 2015

Package AMORE. February 19, 2015

Package pinnacle.api

Configuring Data Masking

Package PACVB. R topics documented: July 10, Type Package

Package TRADER. February 10, 2016

Package Formula. April 7, 2015

NetAdvantage for jquery SR Release Notes

Package bizdays. March 13, 2015

Package ATE. R topics documented: February 19, Type Package Title Inference for Average Treatment Effects using Covariate. balancing.

Developing ASP.NET MVC 4 Web Applications

Package plan. R topics documented: February 20, 2015

Package fastghquad. R topics documented: February 19, 2015

Package SHELF. February 5, 2016

Package cpm. July 28, 2015

HOW TO CREATE THEME IN MAGENTO 2

Package whoapi. R topics documented: June 26, Type Package Title A 'Whoapi' API Client Version Date Author Oliver Keyes

>

Programming Fundamentals of Web Applications Course 10958A; 5 Days

Package RCassandra. R topics documented: February 19, Version Title R/Cassandra interface

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Package fractional. February 15, 2016

Phishing by data URI

Package ROC632. February 19, 2015

Google Sites: Creating, editing, and sharing a site

Package colortools. R topics documented: February 19, Type Package

Package dunn.test. January 6, 2016

Package wordnet. January 6, 2016

Create a GAME PERFORMANCE Portfolio with Microsoft Word

Package PKI. February 20, 2013

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Package date. R topics documented: February 19, Version Title Functions for handling dates. Description Functions for handling dates.

Package CDNmoney. R topics documented: May 1, Version

HOW TO CREATE AN HTML5 JEOPARDY- STYLE GAME IN CAPTIVATE

Package SurvCorr. February 26, 2015

General Information. Getting Started. Curriculum Overview

Designing HTML ers

Package MDM. February 19, 2015

Package rivr. October 16, 2015

What is Memento. Content

Package tablaxlsx. R topics documented: June 9, 2016

ACE: Dreamweaver CC Exam Guide

CA Callahan SharePoint Services MVP CallahanTech

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Package biganalytics

Enterprise Asset Management System

Package syuzhet. February 22, 2015

Package BioFTF. February 18, 2016

Transcription:

Package whisker February 20, 2015 Maintainer Edwin de Jonge <edwindjonge@gmail.com> License GPL-3 Title {{mustache}} for R, logicless templating Type Package LazyLoad yes Author Edwin de Jonge logicless templating, reuse templates in many programming languages including R Version 0.3-2 URL http://github.com/edwindj/whisker Date 2010-12-23 Collate 'whisker.r' 'section.r' 'parsetemplate.r' 'partials.r' 'inverted.r' 'pkg.r' 'iteratelist.r' 'delim.r' 'markdown.r' 'rowsplit.r' Suggests markdown NeedsCompilation no Repository CRAN Date/Publication 2013-04-28 07:55:20 R topics documented: whisker-package...................................... 2 iteratelist.......................................... 3 rowsplit........................................... 4 whisker.escape....................................... 4 whisker.render........................................ 5 Index 6 1

2 whisker-package whisker-package Mustache for R Details Whisker is a templating engine for R conforming to the Mustache specification. Mustache is a logicless templating language, meaning that no programming source code can be used in your templates. This may seem very limited, but Mustache is nonetheless powerful and has the advantage of being able to be used unaltered in many programming languages. For example it make it very easy to write a web application in R using Mustache templates and where the browser can template using javascript s "Mustache.js" Mustache (and therefore whisker) takes a simple but different approach to templating compared to most templating engines. Most templating libraries for example Sweave and brew allow the user to mix programming code and text throughout the template. This is powerful, but ties a template directly to a programming language. Furthermore that approach makes it difficult to seperate programming code from templating code. Whisker on the other hand, takes a Mustache template and uses the variables of the current environment (or the supplied list) to fill in the variables. Examples template <- Hello {{name}} You have just won ${{value}}! {{#in_ca}} Well, ${{taxed_value}}, after taxes. {{/in_ca}} data <- list( name = "Chris", value = 10000, taxed_value = 10000 - (10000 * 0.4), in_ca = TRUE ) whisker.render(template, data) base <- <h2>names</h2> {{#names}} {{> user}} {{/names}} user <- <strong>{{name}}</strong>

iteratelist 3 names <- list(list(name="alice"), list(name="bob")) whisker.render(base, partials=list(user=user)) iteratelist Create an iteration list from a R object In some case it is useful to iterate over a named list or vector iteratelist will create a new unnamed list with name value members: each item will be a list where name is the corresponding name and value is the original value in list x. iteratelist(x, name = "name", value = "value") x name value list or other object that will be coerced to list character name for resulting name member. character name for resulting value member. Value unnamed list with name value lists Examples # create an iteration list from a named vector x <- c(a=1, b=2) iteratelist(x) # iterate over the members of a list x <- list(name="john", age="30", gender="male") iteratelist(x, name="variable") # iterate over an unnamed vector values <- c(1,2,3,4) template <- {{#values}} * Value: {{.}} {{/values}} whisker.render(template)

4 whisker.escape #or values <- iteratelist(values, value="count") template <- {{#values}} * Value: {{count}} {{/values}} whisker.render(template) rowsplit Split a data.frame or matrix into rows Utility function for splitting a data.frame into rows. In a whisker template it can be useful to iterate over the rows of a data.frame or matrix. For example rendering a table in HTML. x rowsplit(x,...) data.frame or matrix... other options will be passed onto split whisker.escape escape basic HTML characters This method is called for normal mustache keys whisker.escape(x) x character that will be escaped Value HTML escaped character

whisker.render 5 whisker.render Logicless templating Logicless templating whisker.render(template, data = parent.frame(), partials = list(), debug = FALSE) template data partials debug character with template text named list or environment with variables that will be used during rendering named list with partial templates, will be used during template construction Used for debugging purposes, likely to disappear Value character with rendered template Examples template <- "Hello {{place}}!" place <- "World" whisker.render(template)

Index iteratelist, 3 rowsplit, 4 split, 4 whisker-package, 2 whisker.escape, 4 whisker.render, 5 6