Skip to content

Support for jinja's block assignments #511

@seijikun

Description

@seijikun

Support for Jinja's Block Assignments would be nice.
These allow writing {% set <var_name> %} blocks that store the block-content to the variable name:

{% set navigation %}
    <li><a href="/">Index</a>
    <li><a href="/{{downloads_url}}">Downloads</a>
{% endset %}

Filters applied to the variable name will be applied to the block’s content:

{% set reply | wordwrap %}
    You wrote:
    {{ message }}
{% endset %}

My idea of implementing this would be somewhere along the lines of generating:

{
    let mut __askama_writer = String::new();
    // ... block-content as rust code
    __askama_writer
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions