Hand in hand with parsers, preprocessors are the heart of director. The idea is to allow the developer to do any additional stuff prior to sourcing an R file. For example, if some helper functions are desired or some operators should be overloaded for a DSL (domain-specific language), the preprocessor can perform this prior to sourcing the R file.

preprocessor(object, ..., parse. = TRUE)

Arguments

object

active_resource. See active_resource.

...

additional parameters to pass to the next layer in the resource parsing tower.

parse.

logical. Whether or not to apply the parser to the resource. If FALSE, this is equivalent to sourcing the resource's file without running its parser. By default, TRUE.

Value

The parsed resource if parse. = TRUE, and the preprocessed resource otherwise.

Details

To define a preprocessor for routes in a given path, you can use the register_preprocessor method on the director object.

Note

The parameters must be named object and ... due to this method's inclusion in a tower.

See also

register_preprocessor, active_resource, tower