Last modified: 2012-02-09 20:39:32 UTC
> {{ #ask: ... > | ?Code > | ?Title > | ?Modification date > | format = ol/ul/template > | template = template name > | named args = yes (default is no) > | debug = yes (default is no) > }} If `named args' is `yes' (or something else evaluated by `Validator' as true), `template name' template will be called using named arguments, not positional. Names of arguments are printout labels, including leading question mark. It increases readability of template code. Instead of > {{{1}}}. {{{2}}} (modified on {{{3}}}) code looks like: > {{{?Code}}}. {{{?Title}}} (modified on {{{?Modification date}}}) Additionally, if `debug' is `yes' (or another true value), template is *not* expanded. It helps to debug issues. If you consider the patch useful, I will add messages and update documentation.
Created attachment 9554 [details] Implementation of the named args.
Patch looks valid - nice work :) In what way is the behaviour of debug=on different from not proving the template param? In any case, I don't think debug is an appropriate name for this parameter. It's behaviour is really specific, and applies only to the template param, while the name is very general. And it might be confused with format=debug.
> In what way is the behaviour of debug=on different from not proving the template param? Hmm... Not providing the `template' argument: > # Waypoint id OCSU18#01 (Location no 1 Location title Point 1 Coordinates 55° 0.010' С, 55° 0.001' В) > # Waypoint id OCSU20#01 (Location no 1 Location title The first Coordinates 55° 0.000' С, 55° 0.000' В) > # Waypoint id OCSU20#02 (Location no 2 Location title The second Coordinates 55° 0.000' С, 55° 1.000' В) `template' argument specified, and `debug' is `yes': > # {{test|1=OCSU18#01|2=1|3=Point 1|4=55° 0.010' С, 55° 0.001' В|#=0}} > # {{test|1=OCSU20#01|2=1|3=The first|4=55° 0.000' С, 55° 0.000' В|#=1}} > # {{test|1=OCSU20#02|2=2|3=The secondя|4=55° 0.000' С, 55° 1.000' В|#=2}} I do not insist on the name and on parameter itself... I can drop it. It was very helpful to me when used template with `map' format and could not understand what is going on. But using named arguments solves most of the issues. However, it still could be use useful to see implicit arguments. For example, `#' argument is not described in the manual. `map' format passes even more implicit arguments.
Created attachment 9557 [details] Attempt #2, no `debug' parameter. `debug' parameter dropped.
Applied in r104296, thnx for the patch :) I'm not sure "named args" is the best way to name this param. "namedargs" might be better. Topic for the list I'd say.
Created attachment 9563 [details] Message. > I'm not sure "named args" is the best way to name this param. "namedargs" might be better. You decide. I think you would prefer `namedparams'. ;-) Attached a patch for message file -- documentation string for `named args'.
Oops, mistake -- wrong message id. Ok, anyway it likely should be fixed when you settle down with exact name of the parameter.
Nice, this has been long overdue! Would it make sense to also include a general setting (e.g. $smwgNamedArgsForTemplates)?
(Why was this reopened now?)
> $smwgNamedArgsForTemplates Sure, but maybe $smwgNamedTemplateArgs is better (it's shorter)
Verified on v1.7.0.2.