Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable jinjax for specific lines #74

Closed
ikus060 opened this issue Jun 26, 2024 · 2 comments
Closed

How to disable jinjax for specific lines #74

ikus060 opened this issue Jun 26, 2024 · 2 comments

Comments

@ikus060
Copy link

ikus060 commented Jun 26, 2024

Hello,

I'm very new to JinjaX and I have an issue while trying to integrate it with an existing Jinja2 application.

I have this line of code in my jinja template. It assign a very specific string value to a variable and it should not get expanded by JinjaX.

{% set dom_without_length_change = "<'d-sm-flex align-items-center'<'mb-1 flex-grow-1'i><'mb-1'f><B>><'row'<'col-sm-12'rt>><'row'<'mt-2'p>>" %}

When compiling template, I get this error.

jinja2.exceptions.TemplateSyntaxError: Unclosed component <B>

Is it possible to disable JinjaX rendering for this specific line. Or maybe there is another workaround ?

Thanks

@ikus060
Copy link
Author

ikus060 commented Jun 26, 2024

Ho I think I figure it out looking at the code. I'm not sure it's this feature is document in the doc.

{% raw %}
{% set dom_without_length_change = "<'d-sm-flex align-items-center'<'mb-1 flex-grow-1'i><'mb-1'f><B>><'row'<'col-sm-12'rt>><'row'<'mt-2'p>>" %}
{% endraw %}

@jpsca
Copy link
Owner

jpsca commented Jun 27, 2024

This works:

{% set dom_without_length_change = "<'d-sm-flex align-items-center'<'mb-1 flex-grow-1'i><'mb-1'f><" + "B>><'row'<'col-sm-12'rt>><'row'<'mt-2'p>>" %}

Sorry, it's a crappy solution, but it works. Someday I'll use a real parser instead of regular expressions

@jpsca jpsca closed this as completed Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants