Description Usage Arguments Details Value Examples
This function reads the contents of a file and performs a search-and-replace on a set of given variable names with given values. In the context of a CGI script, this function is useful for interpolating HTML templates and using them as the HTTP response. variable occurrences are marked with a sentinel character, which defaults to "%".
1 | interpolate(filename, values, sentinel = "%")
|
filename |
the name of the file containing the text to be interpolated |
values |
a named vector, in which the names are used as the variable names, and the values as the variable values. |
sentinel |
a sentinel character indicating a variable in the text. Defaults to "%". |
For example, given the text "Hello %foo" and the variable foo="World", the interpolation will produce the text "Hello World"
the interpolated text.
1 2 3 | error <- "Insufficient amount of coffee!"
errorHTML <- interpolate("../../html/app/error.html",c(message=error))
respondHTML(errorHTML)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.