Posted by gerdami on 20 Nov 2008 11:32, last edited by GoVegan on 09 May 2010 05:51
Tags: include special-character variable
The [[include …]] tag allows to specify include variables — placeholders, together with arbitrary text strings (the include variable's value) that will replace them on the included page.
Although, in general, include variable values may contain any character, some characters may be challenging to enter.
Closing Brackets
If you follow the inc example in the Wikidot syntax documentation
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever
| variable_name = just a variable
| variableName = another variable
]]
and try to add an include variable whose value ends in two (or more) closing brackets (like [[size smaller]]Text to display[[/size]]) with this code
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever
| variable_name = just a variable
| variableName = another variable
| text = [[size smaller]]Text to display[[/size]]
]]
it will fail. Consecutive closing brackets at the very end of an include statement's line will end the include.
Most of the time you can avoid having consecutive closing brackets at the end of a line, by moving the pipe (“|”) symbols (that are separating adjacent include variables) to the end of the line. In the case of the last (or only ) include variable in an include, you can either
- move the two closing brackets (that end the include) to the end of the line, or
- add a pipe (“|”) symbol after the last (or only) include variable (additional pipe symbols do not hurt)
Thus a working code would look like this:
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever |
variable_name = just a variable |
variableName = another variable |
text = [[size smaller]]Text to display[[/size]] ]]
Cannot Move Pipe Symbol to Line End
In case you cannot move a pipe symbol to the end of the line, because the Wikidot syntax requires you to write a tag on its own line ([[include …]] is an example) here's a workaround.
Let's assume you want the value of an include variable to be the following (the value itself should contain another [[include …]]):
Text before include
[[include boilerplate]]
Text after include
Coding
[[include pagename
text=Text before include
[[include boilerplate]]
Text after include
]]
would fail (as the [[include boilerplate]]'s closing brackets end the outer include). Instead you might use:
[[include pagename
text=Text before include
[[include boilerplate{$br}]
Text after include |
br=]
]]
Pipe Symbol
An even bigger challenge poses the pipe symbol (“|”).
If you try to add an include variable whose value contains an internal link (like [[[page|link text to show]]]) with the code
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever
| variable_name = just a variable
| variableName = another variable
| link = [[[page|link text to show]]]
]]
it will again fail. The pipe symbol within the internal link is interpreted as an include variable separator so that the value of “link” becomes [[[page only.
There is no general solution how to include a pipe symbol in an include variable value, but for special cases there are workarounds.
Rewrite Internal Link
To avoid having to use a pipe symbol in an internal link, rewrite the link in the alternate format.
[/page link text to show]
Note that for the alternate format the link text is mandatory, whereas for the standard internal link format the link text is optional, so for some cases this workaround introduces an incompatibility.
Include a Page with Pipe Symbol
Here's another idea:
[[include pagename
link=[[[page
[[include :csi:pipe]{$br} |
link text to show]]] |
br=]
]]
which includes this page (containing a single “|” symbol)
Backlinks
Author
ErichSteinboeck. Please visit his/her userPage.
The matter with the pipe character is a substantial bug that needs to be fixed.
Jay Bienvenu | Hilinqwo: A constructed language
Why dont you just put the special character in the included page itself, not in the variable value?
Instead of
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever
| variable_name = just a variable
| variableName = another variable
| link = [[[page|link text to show]]]
]]
you just put in your included page
and the include syntax is:
[[include pagename var1=value1 | number_books = 43 | title=Best Wiki Ever
| variable_name = just a variable
| variableName = another variable
| page = someurl
| linktext = flowerywords
]]
Admittedly it will cost you another variable in this case, but it's handy in many other cases. I've tested with links (page only, link text only, or both), user (by [[*user {$author}]]), size with all kinds of unit ([[size {$size}]]Look, Im a resizable text.[[/size]]) and all work well.
This will reduce the flexibility of the value, but on the second hand, if you already have a strict formula, I have the notion that to edit one included page will avoid mistakes better than to repeatedly type [[[]]] in pages with includes..
Or I have overlooked some profound things being a newbie? @_@
You seemed to have grasped onto the syntax really well for a newbie! Well done!
The thing I don't like about your method is that you can't set the link inline within an existing variable (as you can with the method documented on this page). But indeed it is a far simpler solutions to the problem at hand.
The easiest way to have multiple closing brackets at the end of the line in an include is to add an extra space after the brackets. I will note the space with _ in the following example.
The code above is tested and works.
I only needed the pipe for a couple of links. I fixed this by using the regular one bracket link.
> add an extra space after the brackets
North, I'd rather discourage use of trailing blanks.