[Moin-user] Defining custom variables

R.Bauer rb.proj at gmail.com
Thu Oct 30 11:34:02 EDT 2008


Greg Ward schrieb:
> 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
> page:
> 
>   Please visit <<GetVal(gward/MyDict, HOMEPAGE)>>
> 
> then the HTML looks like
> 
>   Please visit [[http://www.gerg.ca/|my personal home page]]
> 
> Oops!

Well you asked for the value not for the rendered result. formatter.text
is used for output. (sorry I should not have used the word "expanded" in
my explaination.)

cheers
Reimar

feel free to add the description improvement on http://master18.moinmo.in

please read beforehand http://moinmo.in/EditingOnMoinMaster



> 
>         Greg
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/





More information about the Moin-user mailing list