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

XML comments outside root node cause py:else to raise XMLTemplateCompileError #47

Open
chrislast opened this issue Sep 7, 2020 · 0 comments

Comments

@chrislast
Copy link

chrislast commented Sep 7, 2020

Adding XML comment using <!-- comment --> outside the root node seems to cause an unnecessary and confusing exception in py:else handling.

d="""
<!-- stuff -->
<a>
  <py:switch test="val">
    <py:case value="1">2</py:case>
    <py:else>1</py:else>
  </py:switch>
</a>
"""
>>> dd=kajiki.XMLTemplate(d)
...
kajiki.xml_template.XMLTemplateCompileError: [<string>:6] py:else directive must be inside a py:switch or directly after py:if without text or spaces in between

Without py:else this works fine:

>>> e="""
<!-- stuff -->
<a>
  <py:switch test="val">
    <py:case value="1">2</py:case>
  </py:switch>
</a>
"""
>>> ee=kajiki.XMLTemplate(e)
>>> print(ee(dict(val=1)).render())
<a>
  2
</a>
>>>

With py:else and without XML comment also works fine

>>> f="""
<a>
 <py:switch test="val">
   <py:case value="1">2</py:case>
   <py:else>1</py:else>
 </py:switch>
</a>"""
>>> ff=kajiki.XMLTemplate(f)
>>> print(ff(dict(val=1)).render())
<a>
   2
</a>
>>> print(ff(dict(val=7)).render())
<a>
   1
</a>
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

1 participant