render#
- langchain_core.utils.mustache.render(template: str | list[tuple[str, str]] = '', data: Mapping[str, Any] = mappingproxy({}), partials_dict: Mapping[str, str] = mappingproxy({}), padding: str = '', def_ldel: str = '{{', def_rdel: str = '}}', scopes: list[Literal[False, 0] | Mapping[str, Any]] | None = None, warn: bool = False, keep: bool = False) str [source]#
Render a mustache template.
Renders a mustache template with a data scope and inline partial capability.
- Parameters:
template (str | list[tuple[str, str]]) โ A file-like object or a string containing the template.
data (Mapping[str, Any]) โ A python dictionary with your data scope.
partials_path โ The path to where your partials are stored. If set to None, then partials wonโt be loaded from the file system (defaults to โ.โ).
partials_ext โ The extension that you want the parser to look for (defaults to โmustacheโ).
partials_dict (Mapping[str, str]) โ A python dictionary which will be search for partials before the filesystem is. {โincludeโ: โfooโ} is the same as a file called include.mustache (defaults to {}).
padding (str) โ This is for padding partials, and shouldnโt be used (but can be if you really want to).
def_ldel (str) โ The default left delimiter (โ{{โ by default, as in spec compliant mustache).
def_rdel (str) โ The default right delimiter (โ}}โ by default, as in spec compliant mustache).
scopes (list[Literal[False, 0] | ~collections.abc.Mapping[str, ~typing.Any]] | None) โ The list of scopes that get_key will look through.
warn (bool) โ Log a warning when a template substitution isnโt found in the data
keep (bool) โ Keep unreplaced tags when a substitution isnโt found in the data.
- Returns:
A string containing the rendered template.
- Return type:
str