Implement {% if ... %}

This commit is contained in:
RunasSudo 2025-05-14 18:27:31 +10:00
parent 21b5295cf3
commit 269f0a6e8f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -79,6 +79,20 @@ class Parser:
# {% endblock %}
self.emitter.end_block()
self.in_html = False
elif command.startswith('if '):
# {% if ... %}
condition = command[len('if '):].strip()
self.emitter.emit('if (' + condition + ') {')
elif command.startswith('elif '):
# {% elif ... %}
condition = command[len('elif '):].strip()
self.emitter.emit('} else if (' + condition + ') {')
elif command == 'else':
# {% else %}
self.emitter.emit('} else {')
elif command == 'endif':
# {% endif %}
self.emitter.emit('}')
elif command.startswith('page '):
# {% page ... %}
page_name = command[len('page '):].strip()