include

.include path:{String} sandbox:{ContextSandbox = ContextSandbox.SHARE} -> Any

This function has two behaviors:

  • Reads a Quarkdown file and includes its parsed content in the current document, using the specified sandbox strategy to determine what information is shared between the main context and the included file's context.

  • Loads a library into the current context. Loadable libraries are fetched from the library folder (--libs CLI option). sandbox is ignored in this case.

The context of the included file is always inherited from the main file, with an updated working directory that matches the included file's location. sandbox defines, instead, what information is shared back to the main file's context, and how. The following modes are listed in ascending order of isolation:

  • share (default): exchanges information bi-directionally. Changes made in the included file's context are reflected in the main file's context, and vice versa, allowing for full sharing of variables, functions and other declarations. This is represented by SharedContext.

  • scope: like share, but the included file's context does not share new declarations (functions and variables) back to the main file's context. This is the behavior used within lambda blocks, such as foreach, and is represented by ScopeContext.

  • subdocument: no information is shared back to the main file's context, only inherited from it. This also applies to the document info (metadata, title, etc.), This is the behavior used for subdocuments, and is represented by SubdocumentContext.

Return

the content of the file as a node if a file is included, or nothing if a library is loaded

Parameters

path

either a path (relative or absolute with extension) to the file to include, or the name of a loadable library

sandbox

relationship between the main context and the included file's context

Values

Throws

if the loaded Quarkdown source cannot be evaluated

Wiki page

Including other Quarkdown files