Render Jade Template

Share:

Description

Jade is a high performance template engine heavily influenced by Haml.

Usage

1
2
3

Arguments

text

string with jade template.

...

options passed to the compiler, see http://jade-lang.com/api.

locals

local variables used in the template.

Details

Converting a template to HTML text involves two steps. The first step compiles the template with some formatting options into a closure. The binding for this is implemented in jade_compile. The second step calls the closure with optionally some local variables to render the output to HTML.

The jade_render function is a convenience wrapper that does both steps at once. This is slightly faster if you only need to render your template once.

References

Jade documentation: http://jade-lang.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Example from http://jade-lang.com
text <- readLines(system.file("examples/test.jade", package = "rjade"))

# Compile and render seperately
tpl <- jade_compile(text, pretty = TRUE)
tpl()
tpl(youAreUsingJade = TRUE)

# Slightly faster for one-time rendering
jade_render(text, pretty = TRUE)
jade_render(text, pretty = TRUE, locals = list(youAreUsingJade = TRUE))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.