Author: van.de.bugger
Description:
I propose tag <dws>. Preprocessor should discard the tag and all the whitespaces after it. Primary purpose of the tag -- freestyle formatting for templates. Let us consider an example:
* Some introductory text {{ template1 | param1=value1 | param2=value2 | param3=value3 | ... }} continuation {{ template2 | param1=value1 | param2=value2 | param3=value3 | ... }} and, finally, finish.
Not too readable. I would like to reformat it, use linebreaks and indents for better readability. Since leading and trailing whitespace is often ignored in templates, the example could be reformatted to:
* Some introductory text {{ template1 | param1=value1 | param2=value2 | param3=value3 | ... }} continuation {{ template2 | param1=value1 | param2=value2 | param3=value3 | ... }} and, finally, finish.
I can add indents:
* Some introductory text {{ template1 | param1=value1 | param2=value2 | param3=value3 | ... }} continuation {{ template2 | param1=value1 | param2=value2 | param3=value3 | ... }} and, finally, finish.
or add linebreak before template name:
* Some introductory text {{ template1 | param1=value1 | param2=value2 | param3=value3 | ... }} continuation {{ template2 | param1=value1 | param2=value2 | param3=value3 | ... }} and, finally, finish.
but anyway, braces must remain on the same line with surrounding text.
Using <dws> the example could be reformatted to:
* Some introductory text <dws> {{ template1 | param1=value1 | param2=value2 | param3=value3 | ... }} <dws> continuation <dws> {{ template2 | param1=value1 | param2=value2 | param3=value3 | ... }} <dws> and, finally, finish.
Much better to my taste.
This is a simple example. The more complex template code, the more value of good formatting.
Other possible applications:
- Unnamed leading and trailing whitespaces are not ignored in unnamed template arguments. <dws> may be used to format code:
{{ some template with unnamed arguments |first unnamed argument value<dws> |second unnamed argument value<dws> }}
- If someone wants to avoid too long lines in wiki code:
* Linebreak terminates list element, <dws> so entire element must be written in one long line. <dws> But tag dws allows writing it in multiple short lines.
I think there are even more applications... I have been using the tag in my templates for some time and found in extremely helpful.