render.character: Render method for "character" class.

Description Usage Arguments Value Author(s) Examples

View source: R/render.character.R

Description

Rendering is the process of replacing the tags in moustaches by text.

Usage

1
2
## S3 method for class 'character'
render(x, ...)

Arguments

x

an object of class "character".

...

additional parameters.

Value

Rendered character template.

Author(s)

Dennis Walvoort

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(magrittr)
require(whisker)
# render character string
my_template <- "Hello {{name}}. How are you doing?"
my_template %>% 
  render(name = "Winnie the Pooh")

# render table      
my_template <- c(
     "| x | y |",
     "|---|---|",
     "{{#MY_TABLE}}",
     "| {{X}} | {{Y}} |",
     "{{/MY_TABLE}}")
my_table <- data.frame(X = 1:5, Y = letters[1:5])  
my_table
my_template %>% 
render(MY_TABLE = unname(rowSplit(my_table))) %>%
cat
  

spup documentation built on May 1, 2020, 1:07 a.m.