Keeping Long URLs Readable in Movable Type Templates

I've been working on a few projects recently which required numbered pagination at the bottom of the page. This is no problem for the most recent versions of Movable Type, even with static publishing. How to do it is documented quite well here. In the examples in this documentation I found a neat trick unrelated to pagination I want to share.

Basically what this does is create an URL pointing to Movable Type's search script, with a tail of parameters hanging off it. The values of these parameters depend on the output of various MT tags.

You could do all this in one long line of template code, but the above example is much more readable. Each important part of the URL is on its own line, making them much easier to find if something needs changing.

The smart trick about this is in the last line: the 'strip' attribute replaces all whitespace with its own value, which in this case means deleting all of it, 'trim' removes any leading or trailing whitespace (a bit of overkill I think, after 'strip') and the 'setvar' attribute puts the output of the tag in a variable instead of displaying it, in this case back into the search_link variable.

The end result is a variable (search_link) containing the desired URL, properly formatted on one line and ready for use.