Function templates can be used to extend the add_fct() creation
mechanism with your own template, so that you can be even more
productive when building your {shiny} app.
Function template functions do not aim at being called as is by
users, but to be passed as an argument to the add_fct() function.
Arguments
- name
The name of the generated function.
- path
The path to the R script where the function will be written. Note that this path will not be set by the user but via
add_fct().- export
Whether the generated function should be exported.
- ...
Extra arguments, ignored by the default template.
Details
A template function can take the following arguments to be passed
from add_fct():
name: the name of the function
path: the path to the file in R/
export: a TRUE/FALSE value
If you want your function to ignore these parameters, set ... as
the last argument of your function, then these will be ignored. See
the examples section of this help.
Examples
if (interactive()) {
my_tmpl <- function(name, path, ...) {
# Define a template that writes to the function file
write(name, path)
}
golem::add_fct(name = "custom", template = my_tmpl)
}