Opened 4 years ago

Last modified 21 months 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 Maxim Reznik, 4 years ago

In genshi https://pythonhosted.org/Genshi/xml-templates.html#id6:

<ul>
  <li py:attrs="foo">Bar</li>
</ul>

Given foo={'class': 'collapse'} in the template context, this would produce:

<ul>
  <li class="collapse">Bar</li>
</ul>

comment:2 by Maxim Reznik, 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.

comment:3 by Maxim Reznik, 4 years ago

In 5655:

Implement mtl:boolean.xxx="bool-expr" attribute

in XML template processor to support HTML boolean attributes.
Refs #462

comment:4 by vadim.godunko, 21 months ago

Milestone: 0.8.018.0

Milestone renamed

comment:5 by vadim.godunko, 21 months ago

Milestone: 18.019.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.