R/render.R

render <-
    function                            # simple string-interpolation
(
    tmpl                                # template-string
   ,repl                                # replacement assoc-list
   ,varChar = "$"                       # variable-symbol
)
{
    Reduce(
        function(s, n)
    {
        gsub(paste("\\", varChar, n, "\\", varChar, sep = ""),
             repl[[n]], s)
    }
        ,names(repl)
        ,tmpl
        )
}
michelk/template.R documentation built on May 22, 2019, 9:55 p.m.