1

Is it possible to do a tal:replace="whatever" but maintain certain attributes of the element/tag?

For example, if you have the following:

<input type='text' value='test' name='hello' class='specialClass' tal:replace="customInput"/>

Is it possible to have your customInput replace the current input but somehow also have the specialClass class as well?

I can't tell if PHPTAL allows things like this or if I need to override some PHPTAL method for replacing...

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jake Wilson
  • 88,616
  • 93
  • 252
  • 370

1 Answers1

1

No, you can't. tal:replace completely replaces the element with text, so there is nothing to put these attributes on.

Attributes are preserved with tal:content.

In case of <input>, you'd rather use value="${customValue}" or tal:attributes="value customValue".

PHPTAL doesn't parse any markup at run time, so if you have something that generates <input>'s HTML dynamically for you, then you need to modify that code yourself.

Kornel
  • 97,764
  • 37
  • 219
  • 309