Register a resource parser.

register_parser(path, parser = function() { }, overwrite = FALSE,
  cache = FALSE)

Arguments

path

character. The prefix to look for in the director.

parser

function.

overwrite

logical. If TRUE, register_parser will overwrite the route instead of erroring if the path already has a registered parser. The default is FALSE.

cache

logical. Whether or not to cache resources processed with this parser. Cached resources will not be re-parsed if their dependencies have not been modified. This distinction is important, as most resources are factory resources (the object they generate should not be shared across the entire project; instead, a copy should be made). The default is FALSE.

Examples

not_run({ d <- director('some/project') d$register_parser('models', function() { print("I am a ", resource, ", a model!") }) r <- d$resource('models/some_model.R') r$value() # Will print: I am a models/some_model, a model! })