Opened 6 years ago

Last modified 4 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:


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, 6 years ago

In genshi

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

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

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

comment:2 by Maxim Reznik, 6 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, 6 years ago

In 5655:

Implement"bool-expr" attribute

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

comment:4 by vadim.godunko, 4 years ago


Milestone renamed

comment:5 by vadim.godunko, 4 years ago

Milestone: 18.019.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.