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

py:if and "lower than" comparison #45

Open
cimatosa opened this issue Nov 14, 2019 · 0 comments
Open

py:if and "lower than" comparison #45

cimatosa opened this issue Nov 14, 2019 · 0 comments

Comments

@cimatosa
Copy link

Hi,

after searching for a while I found the solution my self. However, I believe this should make it to the docs.

I was struggling with implementing a py:if comparison like x < 2. The naive way

Template = kajiki.XMLTemplate('''
<html><body>
  <div py:if="x < 2">$title</div>
</body></html>''')

yields an XMLTemplateParseError. This is perfectly correct since the < is a reserves letter in XML. Realizing that, the solution is as simple as replacing < with &lt;.

In doing so I get:

print(Template(dict(title='Kajiki is teh awesome!', x=1)).render())
<html><body>
  <div>Kajiki is teh awesome!</div>
</body></html>
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