Movable Type Documentation > Appendices > Appendix: Template Tag Modifiers

replace

Type: modifier

The replace tag modifier is capable of performing simple string substitutions.

The syntax is a little non-standard because this particular tag modifier takes two arguments: a string to match, and a string to replace it with. Both arguments are encapsulated by quotes and delimited with a comma as follows:

replace="<string to match>","<replacement string>"

Example

The following will replace two HTML line breaks with two real line breaks (which is useful for properly formatting notification emails):

<mt:EntryBody replace="<br /></br />","\n\n">

The following will replace all occurences of the term "Foo" with "Bar" in an entry title:

<mt:EntryTitle replace="Foo","Bar">

As with other tag modifiers, you may repeat the replace attribute multiple times for the same tag to apply multiple operations. And the order they appear will be the order they are applied to the tag.

Related

This page was last updated on 2008-02-23, 13:21.  

Submit a User Contributed Note

User contributed notes are a great way to share the knowledge you have gained in using Movable Type.

If you have a technical question or problem, please visit Movable Type Support.

(If you haven't left a note here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)