Mailing List Archive

template parameters within preformatted blocks
Hello all,

Is there a way to embed a template parameter within a PRE block?

For example, I need a "File" template that is to be used like this:
{{File|file name|file contents}}
The template source might look like this:
'''{{{1|sample file}}}'''
<pre>{{{2|sample contents}}}</pre>

Unfortunately, the second parameter is never resolved, i.e. it shows up
as literal "{{{2|sample contents}}}".
I understand that's because PRE sections are not wikified.

However, the file contents need to be contained within a PRE (or NOWIKI)
block to prevent them from being wikified (e.g. "# comment" would be
transformed into a numbered list otherwise).

Do I have to rely on users wrapping the file contents into PRE tags?


-- F.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
On 28/01/2008, Frederik Dohr <fdg001@gmx.net> wrote:
> Hello all,
>
> Is there a way to embed a template parameter within a PRE block?
>
> For example, I need a "File" template that is to be used like this:
> {{File|file name|file contents}}
> The template source might look like this:
> '''{{{1|sample file}}}'''
> <pre>{{{2|sample contents}}}</pre>
>
> Unfortunately, the second parameter is never resolved, i.e. it shows up
> as literal "{{{2|sample contents}}}".
> I understand that's because PRE sections are not wikified.
>
> However, the file contents need to be contained within a PRE (or NOWIKI)
> block to prevent them from being wikified (e.g. "# comment" would be
> transformed into a numbered list otherwise).
>
> Do I have to rely on users wrapping the file contents into PRE tags?

Try replacing <pre> and </pre> with <pre<noinclude></noinclude>> and
</pre<noinclude></noinclude>>, that sometimes works with these kind of
things.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
Thanks Dr! That was "The core of the poodle". Thanks. -MGrabovsky
Re: template parameters within preformatted blocks [ In reply to ]
Thomas Dalton wrote:
> Try replacing <pre> and </pre> with <pre<noinclude></noinclude>> and
> </pre<noinclude></noinclude>>, that sometimes works with these kind of
> things.

It doesn't, but <noinclude><pre></noinclude> {{{2}}}
<noinclude></pre></noinclude> does.


_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
On 28/01/2008, Platonides <Platonides@gmail.com> wrote:
> Thomas Dalton wrote:
> > Try replacing <pre> and </pre> with <pre<noinclude></noinclude>> and
> > </pre<noinclude></noinclude>>, that sometimes works with these kind of
> > things.
>
> It doesn't, but <noinclude><pre></noinclude> {{{2}}}
> <noinclude></pre></noinclude> does.

That won't work - with that, the preformating will only apply to the
Template: page itself, rather than on pages it's transcluded to.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
I think this email was meant to be in the "Problem with including
subpages" thread:

On 28/01/2008, 65s.mg@atlas.cz <65s.mg@atlas.cz> wrote:
> Thanks Dr! That was "The core of the poodle". Thanks. -MGrabovsky
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l@lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
>

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
> That won't work

I'm afraid that's correct; unfortunately, none of the suggested
workarounds solves the problem (I've tried using a number of different
approaches with NOINCLUDE and INCLUDEONLY).

Maybe with some sort of meta-template (like {{!}})? I'm not sure what
else to try though...


-- F.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
On 28/01/2008, Frederik Dohr <fdg001@gmx.net> wrote:
> > That won't work
>
> I'm afraid that's correct; unfortunately, none of the suggested
> workarounds solves the problem (I've tried using a number of different
> approaches with NOINCLUDE and INCLUDEONLY).
>
> Maybe with some sort of meta-template (like {{!}})? I'm not sure what
> else to try though...

I just tried my method and it works for me (the one with
<pre<noinclude></noinclude>>). Could this be something that's changed
with the new preprocessor? (I'm testing on the latest version from SVN
- I assume you're using a stable version?)

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
> I just tried my method and it works for me (the one with
> <pre<noinclude></noinclude>>).

I'm running v1.11, and I've just tried it on Wikia's 1.12alpha - without
success, I'm afraid:
* Template: http://tinyurl.com/2ugkzt
(http://scratchpad.wikia.com/index.php?title=Template:File&oldid=284739)
* Transcluded: http://tinyurl.com/2so8qr
(http://scratchpad.wikia.com/index.php?title=Scratchpad:Sandbox&oldid=284738)

Oddly enough, it shows up fine on the template's page, but not when
transcluded.
Not sure what I might be doing wrong there...


-- F.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
On 28/01/2008, Frederik Dohr <fdg001@gmx.net> wrote:
> > I just tried my method and it works for me (the one with
> > <pre<noinclude></noinclude>>).
>
> I'm running v1.11, and I've just tried it on Wikia's 1.12alpha - without
> success, I'm afraid:

I think 1.12alpha predates the new preprocessor - try it on Wikipedia
(or just take at look at my sandbox there:
http://en.wikipedia.org/wiki/User:Tango/Sandbox where I have it
working). It seems it is something different with the new
preprocessor. I don't know which is the intended behaviour... (Tim?
Care to comment?) I also don't know if there's another trick that will
work on older versions (since the preprocessor is still in the testing
phase, you may not want to update just yet - hopefully not long,
though, it's being tested on the English Wikipedia, so it must be
nearly ready).

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
Try this: < pre&lt;noinclude&gt;&lt;/noinclude&gt;>your content< /pre&lt;noinclude&gt;&lt;/noinclude&gt;> (without spaces in the tags) -MGrabovsky
Re: template parameters within preformatted blocks [ In reply to ]
Did I understand this right? You are suggesting putting NOINCLUDE within
the opening PRE tag, etc., etc.?

<pre

<noinclude>

</noinclude>>

your content

</pre

<noinclude>

</noinclude>>

jimbo.rules@atlas.cz wrote:
> Try this: < pre&lt;noinclude&gt;&lt;/noinclude&gt;>your content< /pre&lt;noinclude&gt;&lt;/noinclude&gt;> (without spaces in the tags) -MGrabovsky
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
> Try this: [...]

That actually seems to work!
I had tried using HTML entities before, but not in this way...
Either way, thanks very much - I had already given up hope!


-- F.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
Thomas Dalton wrote:
> On 28/01/2008, Platonides wrote:
>> Thomas Dalton wrote:
>>> Try replacing <pre> and </pre> with <pre<noinclude></noinclude>> and
>>> </pre<noinclude></noinclude>>, that sometimes works with these kind of
>>> things.
>> It doesn't, but <noinclude><pre></noinclude> {{{2}}}
>> <noinclude></pre></noinclude> does.
>
> That won't work - with that, the preformating will only apply to the
> Template: page itself, rather than on pages it's transcluded to.

I tested it on wikipedia before posting.
Initially i was going to suggest something like <{{{starttag|pre}}}>
or {{{starttag|<pre>}}} which didn't work


_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
> I tested it on wikipedia before posting.

So Thomas is probably right about the new preprocessor.
Either way, MGrabovsky's solution (using HTML entities) works for me -
I'll try your version after upgrading to the (upcoming) new version.

Thanks to all!


-- F.

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Re: template parameters within preformatted blocks [ In reply to ]
On 28/01/2008, Platonides <Platonides@gmail.com> wrote:
> Thomas Dalton wrote:
> > On 28/01/2008, Platonides wrote:
> >> Thomas Dalton wrote:
> >>> Try replacing <pre> and </pre> with <pre<noinclude></noinclude>> and
> >>> </pre<noinclude></noinclude>>, that sometimes works with these kind of
> >>> things.
> >> It doesn't, but <noinclude><pre></noinclude> {{{2}}}
> >> <noinclude></pre></noinclude> does.
> >
> > That won't work - with that, the preformating will only apply to the
> > Template: page itself, rather than on pages it's transcluded to.
>
> I tested it on wikipedia before posting.

And it worked? Odd... either I'm completely misunderstanding
noinclude, or there's bug there. The pre should be removed when
transcluding it, so the parameter would display as regular text, not
preformatted.

***
I've just tested it myself and you're right, it definitely works. That
looks like a bug to me...

_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l