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.
Arguments:
template β A file-like object or a string containing the template.
data β 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 β 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 β This is for padding partials, and shouldnβt be used
(but can be if you really want to).
- def_ldel β The default left delimiter
(β{{β by default, as in spec compliant mustache).
- def_rdel β The default right delimiter
(β}}β by default, as in spec compliant mustache).
scopes β The list of scopes that get_key will look through.
warn β Log a warning when a template substitution isnβt found in the data
keep β Keep unreplaced tags when a substitution isnβt found in the data.
Returns:
A string containing the rendered template.
- Parameters:
template (str | List[Tuple[str, str]]) β
data (Mapping[str, Any]) β
partials_dict (Mapping[str, str]) β
padding (str) β
def_ldel (str) β
def_rdel (str) β
scopes (List[Literal[False, 0] | ~typing.Mapping[str, ~typing.Any]] | None) β
warn (bool) β
keep (bool) β
- Return type:
str