Help talk:Writing Templates

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

Help[edit]

I'm working on a new template that is intended to color-code the new [[Template:Custom Class|custom class template]] I've thrown together. I've tried to base it on the race color template...and so far I've had no luck. If somebody could [[Template:Specialization Color|take a look]] at the mess I've made and give me some pointers, that would be fantastic! --Eshe 22:42, 9 July 2007 (EDT)

Umm, I'm only just starting to get caught up on what's happened over the last few days. But at first glance it seems like the template is working:
{{Specialization Color|Specialization=Stealth}}
{{Specialization Color|Specialization=Magic}}
{{Specialization Color|Specialization=Combat}}
Those were produced using the template (you probably want to edit the page to see the details). So I'm guessing you're trying to somehow use the template in a different way, and that's why it's not working for you. Or if I'm completely missing something, let me know ;) --NepheleTalk 23:01, 9 July 2007 (EDT)
Okay, it looks like you're right, and so far that template is working. So, I must be trying to use it the wrong way. Right now, in the custom class template, I'm trying to use it like this:
bgcolor={{Specialization Color|{{{Specialization|}}}}}
What I wanted to happen was for the color of the table to change depending on what was entered for "Specialization" when the template is actually used. So, if somebody enters |Specialization=Magic, the table would be the appropriate color. How do I make that work?
You know, really, the thing probably doesn't need to be color-coded...but now that it's got me frustrated, I don't want to give up! --Eshe 23:18, 9 July 2007 (EDT)
The way you've got the template written right now, that chunk of code would need to be:
bgcolor={{Specialization Color|Specialization={{{Specialization|}}}}}
Or, if you'd rather keep the Custom Class template the way that it is, then you need to change the Specialization Color template to start off as:
{{#switch: {{{1|}}}
In other words, right now you're trying to provide the parameter as a numeric parameter, but the template is written to take a named parameter. And as long as it's not getting you too frustrated, working through these kinds of things is really the best way to learn the idiosyncracies of templates :) --NepheleTalk 23:46, 9 July 2007 (EDT)
Phew, got it! Thanks for your help! The custom class template should be fine now, so I'll go ahead and add it to the template category and (hopefully) make a new category for custom classes. --Eshe 00:01, 10 July 2007 (EDT)