register_parser: Register a resource parser.

Description Usage Arguments Examples

Description

Register a resource parser.

Usage

1
2
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

1
2
3
4
5
6
7
## 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!

## End(Not run)

syberia/director documentation built on May 30, 2019, 10:40 p.m.