Content deleted Content added
Looking good |
|||
Line 30:
::::Just curious: why are you changing the sequence of the script? It makes comparing code a bit more difficult. I had the idea of going for 1 Name; 2 Variant; 3 Size; 4 Link; 5 Label - but if there are good reasons to change it I'm all ears.
::::I had trouble with other approaches for <code>{{{link}}}</code> or <code>{{{text}}}</code>. Null string is actually different from no parameter defined. Users can set <nowiki>link=</nowiki> or <nowiki>text=</nowiki> to give specific instructions to the template (no link and same label as name of flag).
:::::I think the only thing I moved out of order was the function default_size (and obviously check_translation that is new), i assigned the name flag_code to territory.args[1] because is used in different points of the script (but maybe the name could be more specific).
::::Regarding the use of parameter do you known that you can have a simpler template call like <code>{{Invoke|Flags|flag}}</code> and access the parameter in lua module using <code>territory:parent().args()</code> ? Is sufficient to add this code to the start of the function:
<syntaxhighlight lang="lua">
function p.flag(territory)
-- get the frame of the calling calling template
local pframe = territory:getParent()
-- get all parameter and store them in a table (pframe return a table with limited function, see scribunto documentation)
local args = {}
for k, v in pairs( pframe.args ) do
args[k] = v
end
</syntaxhighlight >
And then you can check the parameter in the standard way, <code>args[1]</code> por positional parameter 1 and <code>args['text']</code> or <code>args.text</code> for named parameter "text". If text is not definet it will be nil, if its defined but empty <nowiki>text=</nowiki> then it will be equal to the null string <code>""</code>:
Good holiday, I will fly next week. --[[User:Moroboshi|Moroboshi]] ([[User talk:Moroboshi|talk]]) 22:25, 23 July 2013 (UTC)
|