Topic on Project:Support desk

[RESOLVED] Forcing new line in templates

4
194.44.30.6 (talkcontribs)

I'm going to standardize some picture galleries at some non-public wiki using pure templates. The legacy wiki picture/thumbnail galleries are specified with a lot of boilerplate code (it renders a gallery of pictures with thumbnails underneath):


    <center>
    <gallery widths="120px" heights="170px" perrow="5">
    Image:Pic1.jpg|<center>1</center>
    Image:Pic2.jpg|<center>2</center>
    Image:Pic3.jpg|<center>3</center>
    Image:Pic4.jpg|<center>4</center>
    Image:Pic5.jpg|<center>5</center>
    Image:Pic6.jpg|<center>6</center>
    Image:Pic7.jpg|<center>7</center>
    </gallery>
    </center>

This is scary. There is an idea of re-implementing the above code with the following template:


    {{Photos
    | Picture1.jpg = 1
    | Picture2.jpg = 2
    | Picture3.jpg = 3
    | Picture4.jpg = 4
    | Picture5.jpg = 5
    | Picture6.jpg = 6
    | Picture7.jpg = 7
    |}}

The template is mostly as follows:


    ... var definitions, etc ...
    <center>
    {{#tag:gallery
    | {{#forargs: | K | V |
    Image:{{#var: K}} {{!}} <center>'' {{#var: V}} ''</center>
    }}
    | widths = {{#var:WIDTHS}}
    | heights = {{#var:HEIGHTS}}
    | perrow = {{#var:PERROW}}
    }}
    </center>

But the problem is that only the first image is rendered, and the whole rest _Picture 2... Picture 7_ is rendered under the first image thumbnail. And I suspect that the reason possibly is a missing new line character so the gallery tag may be rendered like this producing wrong 1-picture gallery:


    <gallery widths="120px" heights="170px" perrow="5">
    Image:Pic1.jpg|<center>1</center>Image:Pic2.jpg|<center>2</center>Image:Pic3.jpg|<center>3</center>...

It's only an assumption, but I guess it may have strong background. So the question is: is there any way of forcing a new line break so the <gallery> tag could be rendered as expected?

Thanks!

88.130.120.254 (talkcontribs)

Hi!

Only a guess, but does it work when you add a newline inside the template like so?

...
Image:{{#var: K}} {{!}} <center>'' {{#var: V}} ''</center>

    }}
...
194.44.30.6 (talkcontribs)

Hi. Thanks for the suggestion, I've already tried it too and it failed unfortunately. I also tried HTML entity for the \n char, the br-tag - no effect. I've just checked the rendered elements in the browser DOM inspector: all "images" except the first true one are really rendered into a single thumbnail description in div/class=gallerytext as plain text. Have no idea of workaround. :(

194.44.30.6 (talkcontribs)

A guy from S.O. resolved the issue including the <nowiki/> tag like this:

{{#tag:gallery
| {{#forargs: | K | V |<nowiki />
Image:{{#var: K}} {{!}} <center>'' {{#var: V}} ''</center>
}}
| widths = {{#var:WIDTHS}}
| heights = {{#var:HEIGHTS}}
| perrow = {{#var:PERROW}}
}}
Reply to "[RESOLVED] Forcing new line in templates"