- v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
- Use this page to report any issues related to the migration.
Difference between revisions of "User:Sphr/test/test3"
m |
|||
Line 58: | Line 58: | ||
* <nowiki>{{:User:Sphr/f/array2_elem|0|0|3|3|:User:Sphr/test/test4}}</nowiki> will evaluate on the array page as <nowiki>{{:User:Sphr/test/test4|5}}</nowiki> which will evaluate as <nowiki>{{:User:Sphr/test/test4/5}}</nowiki>. | * <nowiki>{{:User:Sphr/f/array2_elem|0|0|3|3|:User:Sphr/test/test4}}</nowiki> will evaluate on the array page as <nowiki>{{:User:Sphr/test/test4|5}}</nowiki> which will evaluate as <nowiki>{{:User:Sphr/test/test4/5}}</nowiki>. | ||
This is a dirty fix to demonstrate the idea; you could probably find something much cleaner. [[User:VengefulDonut|VengefulDonut]] 00:58, 9 January 2008 (EST) | This is a dirty fix to demonstrate the idea; you could probably find something much cleaner. [[User:VengefulDonut|VengefulDonut]] 00:58, 9 January 2008 (EST) | ||
+ | ::ok. just to get myself orientated. From what you described, it seems that I must breakup the content of an "array" into subpages? That has been something that I wanted to avoid. Actually trying to see if there's a way to store and use "arrayed" data in an easier manner and I think creating one subpage for each element is a little overkill. Still, the need for subst atm is limiting but still somewhat useful in cases where we just need a one-time insertion of data without need to look it up. But maybe the real solution is to await the upgrade of wiki engine to support the newer parser functions.... -- [[User:Sphr|Sphr]] 02:22, 9 January 2008 (EST) |
Revision as of 07:22, 9 January 2008
array test:
3x3 array (row|col|data) : 3|3|a|b|c|d|e|f|g|h|i
element(0,0): 0
element(0,1): 1
element(0,2): 3
element(1,0): 3
element(1,1): a
element(1,2): b
element(2,0): c
element(2,1): d
element(2,2): e
{{:User:Sphr/test/test4}}
{{{ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{{1}}} }} }} }}}
element(0,0): {{:User:Sphr/f/array2_elem|0|0|{{subst:User:Sphr/test/test4}}}}
element(0,0): 0
element(0,0): {{{ {{:User:Sphr/f/minus_{{{4}}}|{{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_{{ :User:Sphr/f/inc_ {{{4}}} }} }} }} }} }}}} }}}
{{{ {{ :User:Sphr/f/dec_ {{ :User:Sphr/f/dec_ {{ :User:Sphr/f/dec_{{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_{{:User:Sphr/f/add_{{{2}}}|{{:User:Sphr/f/mult_{{{1}}} | 3 }}}} }} }} }} }} }} }} }} }}}
{{ :User:Sphr/f/array2_elem|1|1| {{{ {{ :User:Sphr/f/dec_ {{ :User:Sphr/f/dec_ {{ :User:Sphr/f/dec_{{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_ {{ :User:Sphr/f/inc_{{:User:Sphr/f/add_{{{2}}}|{{:User:Sphr/f/mult_{{{1}}} | 3 }}}} }} }} }} }} }} }} }} }}} }}
Is there a way to render text as template directly?
element(0,0): {{{ {{:User:Sphr/f/array2_index|{{{1}}}|{{{2}}}|{{{3}}}|{{{4}}}}} }}}
notes:
have to use subst. how to do it by reference?
Possibly order of evaluation is outside in, which prob results in {{subst:User:Sphr/test/test4}} not being evaluated first.
- I think you're correct about evaluation order. I think this could be solved by making the User:Sphr/f/array2_elem function recieve a reference instead of trying to pass the entire array. VengefulDonut 13:15, 8 January 2008 (EST)
- lol, this is not really a programming language. There is no "passing" of variables by reference or otherwise. It is more like lexical substitution. Thus, I don't have a good way to solve the above problem yet. If only I know a way to do substring extraction in mediawiki..... -- Sphr 21:40, 8 January 2008 (EST)
- I think I explained myself poorly. I thought the analogy was clearer. Since you can't substitute a line of text into a template's input (order of evaluation is wrong), you can instead include the name of another template and have your array template extract the element from there. The simplest example I can think of:
- lol, this is not really a programming language. There is no "passing" of variables by reference or otherwise. It is more like lexical substitution. Thus, I don't have a good way to solve the above problem yet. If only I know a way to do substring extraction in mediawiki..... -- Sphr 21:40, 8 January 2008 (EST)
- replace the outside {{{x}}} of User:Sphr/f/array2_elem with {{{{{5}}}|x}}. (the x refers to everything in between).
- use {{:User:Sphr/f/array2_elem|0|0|3|3|:User:Sphr/test/test4}}.
- change User:Sphr/test/test4 to {{:User:Sphr/test/test4/{{{1}}}}}
- put the nececcary things in test4's subpages
- {{:User:Sphr/f/array2_elem|0|0|3|3|:User:Sphr/test/test4}} will evaluate on the array page as {{:User:Sphr/test/test4|5}} which will evaluate as {{:User:Sphr/test/test4/5}}.
This is a dirty fix to demonstrate the idea; you could probably find something much cleaner. VengefulDonut 00:58, 9 January 2008 (EST)
- ok. just to get myself orientated. From what you described, it seems that I must breakup the content of an "array" into subpages? That has been something that I wanted to avoid. Actually trying to see if there's a way to store and use "arrayed" data in an easier manner and I think creating one subpage for each element is a little overkill. Still, the need for subst atm is limiting but still somewhat useful in cases where we just need a one-time insertion of data without need to look it up. But maybe the real solution is to await the upgrade of wiki engine to support the newer parser functions.... -- Sphr 02:22, 9 January 2008 (EST)