LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corepromptsstringjinja2_formatter
    Function●Since v0.1

    jinja2_formatter

    Format a template using jinja2.

    Security

    As of LangChain 0.0.329, this method uses Jinja2's SandboxedEnvironment by default. However, this sandboxing should be treated as a best-effort approach rather than a guarantee of security.

    Do not accept jinja2 templates from untrusted sources as they may lead to arbitrary Python code execution.

    More information.

    Copy
    jinja2_formatter(
        template: str,
        ,
        **kwargs: Any = {},
    ) -> str

    Parameters

    NameTypeDescription
    template*str

    The template string.

    **kwargsAny
    Default:{}

    The variables to format the template with.

    View source on GitHub