Opened 4 years ago
Last modified 2 years ago
#462 new enhancement
Add attribute from template engine
Reported by: | Maxim Reznik | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 19.0 |
Component: | Matreshka - XML Processor | Version: | 0.7.0 |
Keywords: | Cc: |
Description
We need a new construction in template engine to add (or delete?) new attribute of some XML/HTML element.
For instance we have <fieldset>
and we want to convert it to <fieldset disabled>
if some condition is met. Setting disabled="false"
doesn't work, dut to value of attribute doesn't matter in HTML.
The construction could look like:
<mtl:attribute name="disabled">value</mtl:attribute>
Change History (5)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Genshi approach doesn't help me, because I need conditional attribute.
Another idea is to define new 'set of attributes' with name mtl:boolean-*:
<fieldset mtl:boolean-disabled="${boolean-expr}">
Evaluation of this will add attribute 'disabled=disabled' or no attribute depending on boolean-expr.
In genshi https://pythonhosted.org/Genshi/xml-templates.html#id6:
Given foo={'class': 'collapse'} in the template context, this would produce: