-
Notifications
You must be signed in to change notification settings - Fork 14
Node parsing should always treat native django tags as plain text #46
Conversation
…'t try to parse %} as element
2 similar comments
|
||
if stream.text[stream.ptr] in ELEMENT_PREFIXES and not is_variable: | ||
# peek ahead to so we don't try to parse an element from a variable node starting #{ or a Django tag ending %} | ||
if stream.text[stream.ptr] in ELEMENT_PREFIXES and stream.text[stream.ptr:stream.ptr+2] not in ('#{', '%}'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any possibility of indexing out of bounds here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a slice so if it's out of bounds it will just return ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, doh.. not in go. :)
@@ -129,6 +132,10 @@ def test_plain_text(self): | |||
self._test("This should be plain text\n This should be indented", | |||
"This should be plain text\n This should be indented") | |||
|
|||
# native Django tags {% %} should be treated as plain text | |||
self._test("text {%\n trans ''\n%}", "text {%\n trans ''\n%}") | |||
self._test("text\n {%\n trans ''\n%}", "text\n {%\n trans ''\n%}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have a test that starts the Django node at an indent? IE:
.blarg
This is text
{% trans
"hello world
%}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I guess looking at this more closely the second is very close to this..
i.e. don't try to parse %} as an element. This addresses #45