[Python] Jinja nested rendering on variable content

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    Say I have actual jinja template code in a variable X. Let us say the content of X is "{{ some_other_variable }}".

    How can I display X while also rendering its content?

    e.g., this does not work:

    {{ X }}

    As it simply renders this to screen "{{ some_other_variable }}" rather than the contents of some_other_variable.

    The reason I'm doing it this way is that I have a site in which (trusted) users can create posts which themselves may contain jinja template code. The view page displays these posts, but due to the above problem, renders them directly, rather than substituting variables as I'd like.

    Continue reading...

Compartilhe esta Página