Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Node parsing should always treat native django tags as plain text #46

Merged
merged 1 commit into from
Dec 13, 2016

Conversation

rowanseymour
Copy link
Member

i.e. don't try to parse %} as an element. This addresses #45

@rowanseymour rowanseymour added this to the Release 1.0 milestone Dec 13, 2016
@rowanseymour rowanseymour self-assigned this Dec 13, 2016
@coveralls
Copy link

coveralls commented Dec 13, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 90894b1 on ignore_django_tags into b83c677 on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 90894b1 on ignore_django_tags into b83c677 on master.

@coveralls
Copy link

coveralls commented Dec 13, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 90894b1 on ignore_django_tags into b83c677 on master.


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 ('#{', '%}'):

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?

Copy link
Member Author

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 ''

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%}")

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
  %}

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..

@rowanseymour rowanseymour merged commit 62385c7 into master Dec 13, 2016
@rowanseymour rowanseymour deleted the ignore_django_tags branch December 13, 2016 15:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants