PHPTAL replace but keep certain attributes?
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 开发者_如何学Pythoncan't tell if PHPTAL allows things like this or if I need to override some PHPTAL method for replacing...
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.
精彩评论