The append attribute
A handy Perch template feature is the append
attribute. The template engine appends the value of the append
attribute to the end of a field.
Perhaps it is most commonly used when you want to append an ellipsis to truncated text:
<perch:content id="desc" type="textarea" words="50" append="...">
You can also use it instead of littering your template with a bunch of perch:if
tags. Instead of checking whether a field exists to append something like a comma ,
:
<perch:content id="city" type="text"><perch:if exists="city">,</perch:if>
You can use the append
attribute which is only applied if the field exists:
<perch:content id="city" type="text" append=",">