Kelvin,
On Sep 21, 2009, at 7:45 PM, Kelvin Chung wrote:
I have this weird thing with wiki syntax: Consider a
template with
"optional columns", like so:
<snip>
This is clearly, then, caused by the newline between
the canditional
bar and conditional baz lines resolving to empty strings, making the
foo cells in each row have paragraphs containing line breaks. So how
do I get rid of it without, say, putting both rows into one compact
row?
I've spent many an hour being tortured by this "spurious newline"
issue, which seems to me to be one of the weak points in the overall
design of wikitext.
In some cases, it seems to suffice to put the closing "}}" of one line
at the beginning of the next, so that the trailing newline is inside
the {{#if: ...}} scope.
But for the more complex cases, the best I've been able to come up
with is a fairly torturous supplemental template construct:
========== Template "Ifline": ============
<includeonly>{{#if:{{{1}}}|{{{2|}}}}}{{{{#if:{{{1}}}|1x|void}}|
}}</includeonly><noinclude>
This template will magically generate a line or not, according to the
non-nullness of its first positional parameter.
The line generated is taken from the 2nd positional parameter.
The magic here is whether the trailing newline is generated;
that is, if the line is generated, so is that newline,
and, conversely, if the line is not generated, there is no trailing
newline, either.
========== Template "Void": ============
<noinclude>
This template does nothing (it outputs the null string). It's useful
for programming advanced templates.
It often is used within a template to the right of an equals sign.
See, e.g.:
* [
http://meta.wikimedia.org/wiki/Help:Table#Conditional_table_row Help:Table
#Conditional table row]
*
[
http://meta.wikimedia.org/wiki/Help:Newlines_and_spaces#Spaces_and.2For_new…
Spaces and/or newlines as value of an unnamed parameter]
Source: [
http://meta.wikimedia.org/wiki/Template:Void Template:Void]
on ''Meta, a Wikimedia project coordination wiki'' -- 30-Apr-09.
============ END ===========
I can't say I like it, nor can I say that it's at all readable, but it
works.
Paul
______________
Paul C Lustgarten
Applied Research, Enterprise 2.0
AT&T Labs - Research
Florham Park, NJ
+1 973 360 7206