-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Teach template_parser.py about jinja2 whitespace markers. #11516
Comments
Hello @zulip/server-tooling members, this issue was labeled with the "area: tooling" label, so you may want to check it out! |
@zulipbot claim |
Hello @amanpro30, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again. We look forward to your valuable contributions! |
@adnrs96 this is probably an issue for you given your background with the template parser. |
@zulipbot claim |
Hello @kskonanur, it looks like we've already sent you a collaboration invite at https://github.com/zulip/zulip/invitations, but you haven't accepted it yet! Please accept the invite and try to claim this issue again afterwards. We look forward to your contributions! |
@zulipbot claim |
Welcome to Zulip, @ayushah! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip! Here's some tips to get you off to a good start:
As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site. See you on the other side (that is, the pull request side)! |
@zulipbot abandon |
@zulipbot claim |
Reopening because this fix was incomplete. Jinja2 allows you to strip independently from either side of a variable, block, or comment. $ echo '{%- set x = 1 %}' > test.html
$ tools/pretty-print-html test.html
Prettifying: test.html
Traceback (most recent call last):
File "/srv/zulip/tools/lib/template_parser.py", line 163, in tokenize
s = get_jinja2_whitespace_stripped_tag(text, state.i)
File "/srv/zulip/tools/lib/template_parser.py", line 373, in get_jinja2_whitespace_stripped_tag
raise TokenizationException('Tag missing "-%}"', text[i:end+2])
lib.template_parser.TokenizationException: ('Tag missing "-%}"', '{%- set x = 1 %}')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/pretty-print-html", line 21, in <module>
clean_html(filenames)
File "tools/pretty-print-html", line 12, in clean_html
phtml = pretty_print_html(html)
File "/srv/zulip/tools/lib/pretty_print.py", line 15, in pretty_print_html
tokens = tokenize(html)
File "/srv/zulip/tools/lib/template_parser.py", line 172, in tokenize
e.line_content))
lib.template_parser.TemplateParserException: Tag missing "-%}" at Line 1 Col 1:"{%- set x = 1 %}" |
@vrongmeal do you want to take the project of fixing the remaining issue here? |
Being able to use http://jinja.pocoo.org/docs/2.10/templates/#whitespace-control feature would greatly increase the readibility of our template files. Currently
tools/lib/template_parser.py
doesn't seem to know about this feature.To get the error, you can edit a file like
templates/zerver/emails/password_reset.source
, and replace a{% trans %}
,{% endtrans %}
pair with{% trans -%}
,{%- endtrans %}
. Then runtools/lint templates/zerver/emails/password_reset.source
.The text was updated successfully, but these errors were encountered: