Skip to content

[FEATURE] Askama support #1322

@m4tx

Description

@m4tx

Feature Request

I recently tried to use djLint in a Rust project that's using Askama. Askama is a Jinja2-inspired templating engine for Rust. Its most distinctive feature is that the templates are parsed at compile time, which, for instance, allows using Rust functions and macros directly in the template files. See the djLint PR for context: cot-rs/cot#365

It works very well after setting profile="jinja", but has some caveats. For instance, the macro/function formatting acts somewhat weird and replaces some_macro!("foo", bar = baz)? to some_macro!("foo", bar = baz) ?. (notice the space in front of ?) Not a huge problem, but that's not a typical Rust function formatting.

A bigger problem is that it replaces double quotes with single quotes. <a href="{{ foo('bar') }}>" is correct in Python, but not in Rust, since in Rust, single quotes are used to create character literals, rather than strings.

I imagine Rust code formatting might be out of scope for the project, but it would be nice to have an Askama profile built in with at least function formatting turned off. Now I have to explicitly set no_function_formatting=true.

Regardless of that, thanks for creating this project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions