Topic on Extension talk:Variables

How to embed curly braces and quote-marks in variable?

7
Johnywhy (talkcontribs)

This is breaking my template. How to fix? I want the bolded part to be rendered verbatim with #var, but some characters (probably the curly braces) are getting interpreted as active wikitext characters, instead of just loaded into the variable.

{{#vardefineecho:HtmlLink|<htmltag tagname="a" href="/index.php/Portal:Tag?Tag={{{1}}}">}}

elsewhere:

{{#var:HtmlLink}}
Dinoguy1000 (talkcontribs)

The first thing I would try is surrounding the value with a <nowiki></nowiki> tag.

Johnywhy (talkcontribs)

Seems better, but still not rendering as expected.

the following:

{{#vardefineecho:HtmlLink|nowiki <htmltag tagname="a" href="/index.php/Portal:Tag?Tag={{{1}}}"> /nowiki}}

(note, the nowiki tags above ARE surrounded with < and >, but if i include them here then you cannot see the nowiki tags here)

renders, on the template page, as:

<htmltag tagname="a" href="/index.php/Portal:Tag?Tag={{{1}}}">

which is the desired wikitext.

Next, that output should then get parsed as normal wikitext in the template, where #var appears.

But, output of #var is not getting parsed as wikitext in the template, it's just getting rendered on the host-page verbatim, as if it's not wikitext.

It seems the nowiki tag in the #vardefine prevents the output of #var from getting parsed as wikitext.

Any ideas?

Dinoguy1000 (talkcontribs)

I don't think I understand what you're trying to do. What is the problem you're trying to solve here?

Johnywhy (talkcontribs)

i'm re-using a chunk of complex wikitext repeatedly in a Template. So i want to apply that wikitext to a variable for easy re-use, and easy revising.

Up to now, i tried to store the raw wikitext in the variable. But then, as reported above, the wikitext does not get parsed when retrieved with #var.

Next, i'm going to try parsing the wikitext before i store it in the variable-- if i can figure out how. Tips welcomed.

Dinoguy1000 (talkcontribs)

Is there a reason you don't use a subtemplate or metatemplate instead? It sounds like you're trying to use variables as a function of sorts, and that doesn't work; the content of a variable is parsed before it's stored in the variable.

Johnywhy (talkcontribs)

As explain in the OP above, it seems the variable can't be parsed correctly, because curlies in the value confuse your extension. That's why had to wrap it in nowiki.

Thx for telling me about subtemplate and metatemplate, i'll have to learn about that! But i get the general idea that i can use a template for re-used wikitext. Great idea.

Reply to "How to embed curly braces and quote-marks in variable?"