Hi,
I have written some extensions for forms that use template parameters. I have found that it appears to be impossible to pass a template parameter to an extension. I think this make be an upshot of the design, but before I totally give up I thought I'd see if anyone here had tried to do the same thing.
Ideally my extension on a template page would look like this:
<textbox>{{{name|Not set}}}</textbox>
then used like this:
{{form:dynamicform|name=Alex}}
I am embedding them into the webpage as Divs, and then using Java script to mark them up.
However. I cannot get the parser to expand the "name" parameter for my extension. I get passed {{{name|Not Set}}}. OK, so I'll call parsetags, but that seems to only pick up "Not set" when called from my extension, not "Alex".
My eventual solution was partially formed HTML:
<textbox id=name />{{{name}}} <close textbox/>
Note the closed extension tags. The extension hacks around with the parser adding tokens and replacing them after strip tags. It creates an open div tag, and then a close div tag using <close> extension. This works and used properly produces well formed HTML, but is not elegant and is prone to error. I was hoping the new parser ordering might help my plight, but it didn't. Am I going about this the wrong way?
Kind regards,
Alex
On Mon, Mar 31, 2008 at 9:28 AM, Alex Powell alexp@exscien.com wrote:
Hi,
I have written some extensions for forms that use template parameters. I have found that it appears to be impossible to pass a template parameter to an extension. I think this make be an upshot of the design, but before I totally give up I thought I'd see if anyone here had tried to do the same thing.
See this bug report:
Thanks, I'll keep an eye on that one, sounds exactly like my problem...
Alex
On Mon, Mar 31, 2008 at 3:10 PM, Simetrical Simetrical+wikilist@gmail.com wrote:
On Mon, Mar 31, 2008 at 9:28 AM, Alex Powell alexp@exscien.com wrote:
Hi,
I have written some extensions for forms that use template parameters. I have found that it appears to be impossible to pass a template parameter to an extension. I think this make be an upshot of the design, but before I totally give up I thought I'd see if anyone here had tried to do the same thing.
See this bug report:
https://bugzilla.wikimedia.org/show_bug.cgi?id=2257
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
On Mon, Mar 31, 2008 at 3:00 PM, Alex Powell alexp@exscien.com wrote:
Thanks, I'll keep an eye on that one, sounds exactly like my problem...
Alex
On Mon, Mar 31, 2008 at 3:10 PM, Simetrical Simetrical+wikilist@gmail.com wrote:
On Mon, Mar 31, 2008 at 9:28 AM, Alex Powell alexp@exscien.com wrote:
Hi,
I have written some extensions for forms that use template parameters. I have found that it appears to be impossible to pass a template parameter to an extension. I think this make be an upshot of the design, but before I totally give up I thought I'd see if anyone here had tried to do the same thing.
See this bug report:
https://bugzilla.wikimedia.org/show_bug.cgi?id=2257
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
-- Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Thanks Jim,
I'll try that. Squiggly brackets ahoy!
Alex
On Tue, Apr 1, 2008 at 5:45 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
On Mon, Mar 31, 2008 at 3:00 PM, Alex Powell alexp@exscien.com wrote:
Thanks, I'll keep an eye on that one, sounds exactly like my problem...
Alex
On Mon, Mar 31, 2008 at 3:10 PM, Simetrical Simetrical+wikilist@gmail.com wrote:
On Mon, Mar 31, 2008 at 9:28 AM, Alex Powell alexp@exscien.com wrote:
Hi,
I have written some extensions for forms that use template parameters. I have found that it appears to be impossible to pass a template parameter to an extension. I think this make be an upshot of the design, but before I totally give up I thought I'd see if anyone here had tried to do the same thing.
See this bug report:
https://bugzilla.wikimedia.org/show_bug.cgi?id=2257
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
-- Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Hi,
Now I have implemented it as a parser function it looks much cleaner, but now I have a new problem - I cannot seem to call parser->recursiveTagParse or (Parser:parse for that matter) to process the template parameter - which is normal wiki text. The parameters just appear as flat text. The parser object is passed to the function, but doesn't seem to work the same. Am I missing something or is this a limitation of parser functions that recursiveTagParse can only be used by XML style extensions? If so I'll probably have to go back to the old method until the bug Simetrical pointed out has been fixed - though I guess I could try #tag (shudder)...
Alex
On Tue, Apr 1, 2008 at 9:42 PM, Alex Powell alexp@exscien.com wrote:
Thanks Jim,
I'll try that. Squiggly brackets ahoy!
Alex
On Tue, Apr 1, 2008 at 5:45 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
I was wrong about Parser::parse - that *does* seem to parse the tags (wasn't calling getText) when passed with params 4 and 5 as false. However recursiveTagParse still doesn't work. But anyway I'm happy...
On Wed, Apr 2, 2008 at 11:21 PM, Alex Powell alexp@exscien.com wrote:
Hi,
Now I have implemented it as a parser function it looks much cleaner, but now I have a new problem - I cannot seem to call parser->recursiveTagParse or (Parser:parse for that matter) to process the template parameter - which is normal wiki text. The parameters just appear as flat text. The parser object is passed to the function, but doesn't seem to work the same. Am I missing something or is this a limitation of parser functions that recursiveTagParse can only be used by XML style extensions? If so I'll probably have to go back to the old method until the bug Simetrical pointed out has been fixed - though I guess I could try #tag (shudder)...
Alex
On Tue, Apr 1, 2008 at 9:42 PM, Alex Powell alexp@exscien.com wrote:
Thanks Jim,
I'll try that. Squiggly brackets ahoy!
Alex
On Tue, Apr 1, 2008 at 5:45 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
--
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
recursiveTagParse() is really for tag extensions. However, the output from a parser function is inserted into the normal wikitext flow /before/ being rendered into HTML, so you don't have to do it yourself. Just output whatever wikitext you want to have rendered. This facility is what allows parser functions to call eachother, or call one with the output of another (nesting).
However, if you must render the wikitext yourself, you should specify in your output that it's raw html, not wikitext for futher processing. This article talks about how to set that flag:
http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Par...
Good luck!
-- Jim
On Wed, Apr 2, 2008 at 5:33 PM, Alex Powell alexp@exscien.com wrote:
I was wrong about Parser::parse - that *does* seem to parse the tags (wasn't calling getText) when passed with params 4 and 5 as false. However recursiveTagParse still doesn't work. But anyway I'm happy...
On Wed, Apr 2, 2008 at 11:21 PM, Alex Powell alexp@exscien.com wrote:
Hi,
Now I have implemented it as a parser function it looks much cleaner, but now I have a new problem - I cannot seem to call parser->recursiveTagParse or (Parser:parse for that matter) to process the template parameter - which is normal wiki text. The parameters just appear as flat text. The parser object is passed to the function, but doesn't seem to work the same. Am I missing something or is this a limitation of parser functions that recursiveTagParse can only be used by XML style extensions? If so I'll probably have to go back to the old method until the bug Simetrical pointed out has been fixed - though I guess I could try #tag (shudder)...
Alex
On Tue, Apr 1, 2008 at 9:42 PM, Alex Powell alexp@exscien.com wrote:
Thanks Jim,
I'll try that. Squiggly brackets ahoy!
Alex
On Tue, Apr 1, 2008 at 5:45 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
--
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
-- Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
That makes sense. My function did need the stuff rendered before cos I wanted some HTML tags that get stripped by MW, so I found parser->parse()->getText() did the trick, then I do a post parse substitution of the output. Parser functions have made a huge difference though to readability.
Thanks for all the help
Alex
On Thu, Apr 3, 2008 at 6:38 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
recursiveTagParse() is really for tag extensions. However, the output from a parser function is inserted into the normal wikitext flow /before/ being rendered into HTML, so you don't have to do it yourself. Just output whatever wikitext you want to have rendered. This facility is what allows parser functions to call eachother, or call one with the output of another (nesting).
However, if you must render the wikitext yourself, you should specify in your output that it's raw html, not wikitext for futher processing. This article talks about how to set that flag:
http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Par...
Good luck!
-- Jim
On Wed, Apr 2, 2008 at 5:33 PM, Alex Powell alexp@exscien.com wrote:
I was wrong about Parser::parse - that *does* seem to parse the tags (wasn't calling getText) when passed with params 4 and 5 as false. However recursiveTagParse still doesn't work. But anyway I'm happy...
On Wed, Apr 2, 2008 at 11:21 PM, Alex Powell alexp@exscien.com wrote:
Hi,
Now I have implemented it as a parser function it looks much cleaner, but now I have a new problem - I cannot seem to call parser->recursiveTagParse or (Parser:parse for that matter) to process the template parameter - which is normal wiki text. The parameters just appear as flat text. The parser object is passed to the function, but doesn't seem to work the same. Am I missing something or is this a limitation of parser functions that recursiveTagParse can only be used by XML style extensions? If so I'll probably have to go back to the old method until the bug Simetrical pointed out has been fixed - though I guess I could try #tag (shudder)...
Alex
On Tue, Apr 1, 2008 at 9:42 PM, Alex Powell alexp@exscien.com wrote:
Thanks Jim,
I'll try that. Squiggly brackets ahoy!
Alex
On Tue, Apr 1, 2008 at 5:45 PM, Jim R. Wilson wilson.jim.r@gmail.com wrote:
Alex,
Instead of using a <tag>, you should make a {{#parserfunction:}}. The process is similar, but a parser function participates in a much more integrated way with the rest of the parsing process (allowing template parameters for example).
-- Jim R. Wilson (jimbojw)
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
--
Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
-- Alex Powell
Exscien Training Ltd Tel: +44 (0) 1865 920024 Direct: +44 (0) 1865 920032 Mob: +44 (0) 7717 765210
skype: alexp700 mailto:alexp@exscien.com http://www.exscien.com
Registered in England and Wales 05927635, Unit 10 Wheatley Business Centre, Old London Road, Wheatley, OX33 1XW, England
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org