npm install jstransformer-nunjucks
var nunjucks =nunjucksbody//=> 'Hello, World!'var options =filters: s;nunjucksbody//=> 'Hello, Hello, Hello, World!'
See the JSTransformers documentation for other API methods.
By default, this transformer matches the .njk and .nunjucks input file extensions, and outputs .html.
Many of the API methods accept an
options dictionary object. The following option keys are supported:
filename: The filename and path of the Nunjucks template being compiled. Default is null, which disables any imports or includes using relative path names.
root: The base path used to configure the Nunjucks environment. This defines the highest-level directory that can be searched for templates and macros. Any import or include references to files outside this root directory will fail. Default is to use the parent directory of the
filenamepath, if it is specified, or
null(which causes Nunjucks to default to the current working directory).
path: Alternative name for
filters: A set of custom Nunjucks filters to add. The value of
extensions: A set of Nunjucks extensions to add. The value of
globals: A set of global variables available to all templates. The value of
globalsis a dictionary object defining the keys and values of the global data properties.