Skip to content

File template options

new TemplateFileOpts([opts])

Template options for a Node.js file system back-end. See module:templeo/options.FileOptions for a full listing of options.

Parameters

NameTypeDescription
[opts]module:templeo/options.FileOptionsThe template file options

See also

  • module:templeo/options.FileOptions
  • module:templeo/options.Options

TemplateFileOpts.defaultOptionsObject

Returns

See also

  • module:templeo/options.FileOptions
  • module:templeo/options.Options

templeo/options.FileOptions

Template options for a Node.js file/system back-end. All file options inherit from [TemplateOpts]module:templeo/options.Options.

Type: module:templeo/options.Options

Properties

NameTypeDefaultDescription
[relativeTo=.]String.The base directory path that will be used during file read/write operations for partial template content and
generated rendering sources.
[contextPath=views]StringviewsThe path where the context JSON is located relative to the path set by relativeTo. The name of file is determined by
[TemplateOpts.defaultContextName]module:templeo/options.Options.
[templatePath=views]StringviewsThe path where the primary template is located relative to the path set by relativeTo. The name of file is determined
by [TemplateOpts.defaultTemplateName]module:templeo/options.Options. Since the primary template needs to be present prior to compiling,
the option can only be used during compilation and is ignored during rendering.
[partialsPath=views/partials]Stringviews/partialsThe path where the partial templates are located/identified relative to the path set by relativeTo.
Partials are small segments of template code that can be nested and reused throughout other templates. The path is used during read/write
oprtations for prefixing file paths. Any sub-directories within partialsPath will be mirrored within the outputPath or temporary directory.
[watchPaths=false]BooleanfalseWhen true, partialsPath and its discovered subdirectories are watched with native
Node.js fs.watch. Added or changed files are registered/re-registered,
removed files are unregistered, and newly created or removed subdirectories are added to or removed from the active watcher set.
Watchers use { persistent: false }, so they do not keep the Node.js process running. File-system event behavior remains dependent on the
underlying operating system. When enabled at compile-time, watchers remain active until engine.clearCache() is called.
When enabled at render-time, pass the same shared-store object as the renderer's fifth argument across calls; the watchers remain active
until a rendering call sets unwatchPaths to true.
[unwatchPaths=false]BooleanfalseWhen true, all render-time watchers associated with the renderer's shared store are closed.
The rendering function call returns an empty string without rendering.
[outputPath]StringWhen defined and a valid partialsPath is defined, compiled rendering function sources will be written to corresponding
sub-directories mirrored during compilation and partial discovery from Engine.register reads. Omit to use the operating system's
temporary directory.
[outputPathTempPrefix=templeo-files-]Stringtempleo-files-When outputPath is falsy the prefix will be used when generating a temporary directory.
Otherwise, it's ignored.

Released under the MIT License.