langchain_core.utils.mustache
.render¶
- langchain_core.utils.mustache.render(template: Union[str, List[Tuple[str, str]]] = '', data: Dict[str, Any] = {}, partials_dict: Dict[str, str] = {}, padding: str = '', def_ldel: str = '{{', def_rdel: str = '}}', scopes: Optional[List[Union[Literal[False, 0], Dict[str, Any]]]] = None, warn: bool = False, keep: bool = False) str [source]¶
渲染一个mustache模板。
使用数据范围和内联部分功能渲染一个mustache模板。
参数:
template – 一个类似文件的对象或包含模板的字符串
data – 一个包含数据范围的Python字典
partials_path – 存储部分文件的路径 如果设置为None,则部分将不会从文件系统加载 (默认为’.’)
partials_ext – 您希望解析器查找的扩展名 (默认为’mustache’)
partials_dict – 一个Python字典,将在文件系统之前搜索部分 {‘include’: ‘foo’} 相当于一个名为include.mustache的文件 (默认为{})
padding – 用于填充部分,不应该使用 (但如果您真的想要,可以使用)
def_ldel – 默认左定界符 (默认为”{{”,与符合规范的mustache一样)
def_rdel – 默认右定界符 (默认为”}}”,与符合规范的mustache一样)
scopes – get_key将查找的作用域列表
warn – 当在数据中找不到模板替换时记录警告
keep – 当在数据中找不到替换时保留未替换的标签
返回:
包含渲染模板的字符串。
- Parameters
template (Union[str, List[Tuple[str, str]]]) –
data (Dict[str, Any]) –
partials_dict (Dict[str, str]) –
padding (str) –
def_ldel (str) –
def_rdel (str) –
scopes (Optional[List[Union[Literal[False, 0], Dict[str, Any]]]]) –
warn (bool) –
keep (bool) –
- Return type
str