[Moin-user] Defining custom variables

Greg Ward gerg.ward+moin at gmail.com
Fri Oct 24 17:28:15 EDT 2008

On 22 October 2008, R.Bauer said:
> the page MyDict has to be created as a subpage of your homepage
> I have there on my ReimarBauer/MyDict some vars for me defined and I can
> for example write @IMG@ on a page and this is expanded to my image.

Ahh!  Thank you.  That is not clear from HelpOnVariables.  May I suggest
a change:

--- HelpOnVariables.txt.orig    2008-10-24 17:11:16.000000000 -0400
+++ HelpOnVariables.txt 2008-10-24 17:17:53.000000000 -0400
@@ -24,14 +24,14 @@
 || @``MAILTO@   || A fancy mailto: link with the user's data    || None - on public sites, better use the Mail``To macro ||

-== Expanding Variables ==
+== Defining New Variables ==

-You can use Home``Page``Name/My``Dict to expand those variables, just put a dictionary (see HelpOnDictionaries) there with your variables and values. For example,
+If the builtin variables are not enough, you can define new variables by creating a sub-page of your home page with a dictionary of variables in it.  For example, if your username is !JohnDoe, you would create page !JohnDoe/!MyDict with the following content:
- VAR1:: substitution 1
- VAR2:: substitution 2
+ VAR1:: some random text
+ VAR2:: use ''any'' wiki markup
+Then, whenever you edit a page, you can use `@VAR1@` or `@VAR2` to expand to the text in that dictionary.

 == Getting Variables ==


> <<GetVal(ReimarBauer/MyDict,IMG)>>
> is also expanded to the value of the key.

Hmmm. I just tried something like this in a test wiki running 1.8.0rc1.
Putting wiki markup in a variables works fine if I expand at save time
with @VAR at .  But if I use <<GetVal>>, the wiki markup is rendered
literally in the output HTML.

Explanation: page "gward/MyDict" contains just

 NAME:: Greg
 HOMEPAGE:: [[http://www.gerg.ca/|my personal home page]]

When I edit a page to say

  Please visit @HOMEPAGE@!

it works; the wiki markup is inserted into the page text and then
processed into HTML when the page is rendered.  But if I put this in a

  Please visit <<GetVal(gward/MyDict, HOMEPAGE)>>

then the HTML looks like

  Please visit [[http://www.gerg.ca/|my personal home page]]



More information about the Moin-user mailing list