Page MenuHomePhabricator

Trimming or removing all whitespace from returned template text is useful
Closed, ResolvedPublic

Description

Author: dan.bolser

Description:
Diff between r68758 and my changes.

When you have a template that just sets some configuration or inserts a div, for example, it is often nice to leave lots of whitespace in the wiki code for readability. However, this will often affect the layout of the calling page.

Two new parser functions have been proposed to help deal with this issue (although there could be many different ways to deal with it).

<!-- Trim the whitespace from before and after

the text returned by 'template' -->

{{#trim: {{template}} }}

<!-- Remove *all* the whitespace from within

the text returned by 'template' -->

{{#nospaces: {{template}} }}

Attached is a diff that adds these two parser functions to the cleverly named ParserFunctions extension.


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz24182

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:07 PM
bzimport set Reference to bz24182.

dan.bolser wrote:

Here is a 'working' version (see the tests):

http://bifx.org/~dmb/phase3/index.php/Main_Page

Fixed in r69197 (trunk) by creating a new parserfunction #stripnewlines as part of http://www.mediawiki.org/wiki/Extension:StringFunctionsEscaped.

Additional whitespace remove function deemed unnecessary by submitter.