distill: distill: simple brew wrapper

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/distill.R

Description

distill is a simple wrapper for brew. distill provides functionality to generate brew code from simpler markup closer to the E4X language.

Usage

1
distill( txt, brew = FALSE, env = sys.frame(sys.parent()) )

Arguments

txt

The text to distill

brew

Is brew called ?

env

Environment where distilling is performed.

Details

distill consist of generating brew ready templates from a different markup that is (arguably) simpler to use in an XML setting. The following table shows the possible transformations from distill code to brew code.

description distill code brew code
R code to be cat {x} <%=x%>
Loop generator starter <@i|n> <%for(i in 1:n){ %>
Loop generator starter <@i~n> <%for(i in n){ %>
Loop generator starter <@i?n> <%for(i in seq(along = n)){ %>
Loop generator closer </@> <%

%>

Value

a character vector ready to be brewed.

Author(s)

Romain Francois <rfrancois@mango-solutions.com>

References

Jeffrey Horner (2007). brew: Templating Framework for Report Generation.

See Also

xml uses distill to modify the content of XML nodes before parsing. brew

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  y <- "foo"
  txt <- "<test>{x}</test>"
  distill( txt )
  
  cat. <- function(x){
    cat( x, sep = "\n" )
  }
  
  y <- c("foo", "bar")
  txt <- "
    <test>
      <@i~y>
        <foo>{i}</foo>
      </@>
    </test>
    "
  cat.( distill( txt ) )

  txt <- "
    <test>
      <@i|length(y)>
        <foo>{y[i]}</foo>
      </@>
    </test>
    "
  cat.( distill( txt ) )

  txt <- "
    <test>
      <@i?y>
        <foo>{y[i]}</foo>
      </@>
    </test>
    "
  cat.( distill( txt ) )

  

R4X documentation built on May 2, 2019, 4:52 p.m.