terminal-labs / lektor-jinja-content

Render Lektor content fields with Jinja2.
Other
11 stars 5 forks source link

Can't escape endraw tags #17

Open jtraub91 opened 1 year ago

jtraub91 commented 1 year ago

This plugin renders the lektor content as Jinja by design. We may want to write jinja code in the content, however. Usually encapsulating the entire thing in {% raw %} and {% endraw %} tags is good enough, except when you need to use those tags within the content. There doesn't appear to be an intrinsic way to escape {% endraw %} specifically (see comments in https://stackoverflow.com/a/25359906). Using html entities (e.g. {, }, %) could be a solution, but this does not seem to work when nested within a markdown code block, further complicating the issue.

nixjdm commented 1 year ago

There's some non-mutually exclusive ways the plugin could handle this.

For one, there should be a way to disable this plugin per page, field, or page and field. Sometimes you might really want the plugin, and just be able to escape like this though. Maybe to enable that, the plugin could use another custom tag to allow {% endraw %} to pass through as raw itself.