Last modified: 2012-02-09 20:39:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T34654, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32654 - SemanticMediaWiki: Named arguments for template + debug output.
SemanticMediaWiki: Named arguments for template + debug output.
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-26 12:26 UTC by Van de Bugger
Modified: 2012-02-09 20:39 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Implementation of the named args. (2.46 KB, patch)
2011-11-26 12:27 UTC, Van de Bugger
Details
Attempt #2, no `debug' parameter. (2.10 KB, patch)
2011-11-26 19:17 UTC, Van de Bugger
Details
Message. (1.06 KB, patch)
2011-11-26 21:09 UTC, Van de Bugger
Details

Description Van de Bugger 2011-11-26 12:26:57 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.
Comment 1 Van de Bugger 2011-11-26 12:27:36 UTC
Created attachment 9554 [details]
Implementation of the named args.
Comment 2 Jeroen De Dauw 2011-11-26 15:34:39 UTC
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.
Comment 3 Van de Bugger 2011-11-26 15:49:41 UTC
> 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.
Comment 4 Van de Bugger 2011-11-26 19:17:31 UTC
Created attachment 9557 [details]
Attempt #2, no `debug' parameter.

`debug' parameter dropped.
Comment 5 Jeroen De Dauw 2011-11-26 20:06:48 UTC
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.
Comment 6 Van de Bugger 2011-11-26 21:09:53 UTC
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'.
Comment 7 Van de Bugger 2011-11-26 21:12:49 UTC
Oops, mistake -- wrong message id. Ok, anyway it likely should be fixed when you settle down with exact name of the parameter.
Comment 8 s7eph4n 2011-11-26 22:08:48 UTC
Nice, this has been long overdue!

Would it make sense to also include a general setting (e.g. $smwgNamedArgsForTemplates)?
Comment 9 s7eph4n 2011-11-26 22:11:09 UTC
(Why was this reopened now?)
Comment 10 Jeroen De Dauw 2011-11-26 22:17:46 UTC
> $smwgNamedArgsForTemplates

Sure, but maybe $smwgNamedTemplateArgs is better (it's shorter)
Comment 11 Van de Bugger 2012-02-09 20:39:32 UTC
Verified on v1.7.0.2.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links