tal

replace attributes

SOFTWARE: tal
 <a href="/sample/link.html" tal:attributes="href here/sub/absolute_url">

insert a dynamic value. (used a lot in templates in plone.)

Concatenate with static value

The trick here is to use "define" to define something (like a result from a batch operation) first, and then you can reference that value in your attributes replacement by using a python expression. Concatenation is then possible between a static string value (the first part of the url) and the dynamic value (the id) via the + operator.

 <div tal: define="my_thingee_id result/id">
<a href="/sample/link.html" tal:attributes="href python:'http://www.mydomain.com/
some_page.php?view=event&eventid=' + str(my_thingee_id)">
</div>
MORE INFO:

Mix Path Expresssion with Text in Tal:content

SOFTWARE: tal
 <title tal:content="string:DU - ${obj_item/pretty_title_or_id}">Title</title>

To mix in some static text with a dynamic expression when using tal, do something like this:

"string:static_stuff here ${dynamic/expression/here}"

So, it's all about using string: and ${} to designate your static stuff as opposed to your expression.

MORE INFO: http://wiki.zope.org/ZPT/TutorialPart3
Comments