Forum:Example Template for Documentation

The idea is to create a template that first shows the template's wiki code and then shows the output that code is generating. That should help adding examples to a documentation page. Here is what I got so far...

Template:

Use of the Template (on a documentation Page/doc):

But it's evil to have to write the same template call twice. So I am looking for something like this: or or (but don't like using | ...)

Any help is welcome on this :) Vanesyra 22:05, September 4, 2011 (UTC)

Maybe I misunderstood what you want, but I don't see the point of a template like that. Usually the documentation is handled like this, by putting the documentation in a subpage and showing it in the template page through this template. This way the template page isn't overloaded with the documentation. This template is also used to write the code in the examples, or you can always use the tags &lt;pre> Code &lt;/pre> for more complex codes. Feel fre to copy the whole template documentation system, but keep sure to have every templates listed in "dependencies", the categories used and the preloaded pages.


 * Some wikis use also a template like this one which display a notice (only) in the subpage documentation, also it will automatically add the category to the documentation page, so you will not have to add  at the end of the page. If you'll use this template, add it to the preload page.

Here is an example where I wanna use this and for what. Template:Charge and Template:Proc. It's just for adding examples on a documentation page and make sure that this examples get the same layout. Vanesyra 00:21, September 5, 2011 (UTC)


 * As long as you're properly using,  , or  , you can put example uses of your template on the template page itself. It just isn't a good idea to put so much documentation on the template page itself for performance purposes (aka it makes the wiki-engine do alot more work).
 * Is there a reason you don't want to use a subpage for your docs? -- Fandyllic (talk &middot; contr) 4 Sep 2011 5:34 PM Pacific


 * I am using a documentation page for performance purposes already. I just want an more elegant way to add examples to that documentation page. It's always the same... you write to nowiki tag with the code, and then you write the code again to show what the example is doing. I am lazy so I want to write that code only once and let a template do the work for showing wiki code + output of that code. Also that makes sure that all examples get the same layout, whats nice too :) Vanesyra 03:16, September 5, 2011 (UTC)

(edit conflict) Those template make a simply list of feature, they use a switch so you cannot use a template like that for "every template" since there are setted values. Tell me if I got iy right: by writing this, for example:

You want to get something like this:

gives:

am I correct?

For this kind of template, maybe try this code: gives:

With 1= the name of the template. 2=/3=...N= the parameters (use 2=parameter=value for named parameters). I don't know if it will works and I'm pretty sure that there are some bugs, but it's a start.


 * Yes you got it right. That's what I wanna do. The code you provided will work only for none named parameters (At least I think so). But most of the templates got named parameters too. My main problem is that I don't get the wiki to parse and run the wiki text on the example template. no problem to show that code. But I just can't make the wiki rendering that, to show what the example is doing. I always end up in a situation where I get the code displayed OR the rendered template. I never get both at the same time.


 * Exampl 1: calling the template like this will make code preview easy, just need to use  to display it. But how to remove the nowiki tag from  to display the rendering? All parser functions ignore the tags so can't replace / remove / split them away.


 * Example 2: calling it like this and I just have to  to get the code shown. But  will not render it? It will display  ... but it should render that wiki text -.- that's driving me crazy :(


 * Vanesyra 03:16, September 5, 2011 (UTC)