80,736
edits
(Module:Luacard2) |
No edit summary |
||
Line 13: | Line 13: | ||
function map(table, func) | function map(table, func) | ||
if table==nil then return table end | |||
for k,v in pairs(table) do | for k,v in pairs(table) do | ||
table[k] = func(v) | table[k] = func(v) | ||
Line 20: | Line 21: | ||
function filter(table, func) | function filter(table, func) | ||
if table==nil then return table end | |||
local new = {} | local new = {} | ||
for k,v in pairs(table) do | for k,v in pairs(table) do | ||
Line 301: | Line 303: | ||
function apply_related(frame, vars) | function apply_related(frame, vars) | ||
-- we use cardname_e and just show english | -- we use cardname_e and just show english related | ||
vars.related = {} | |||
vars.cardnotes = {} | |||
local related_set = relatedquery(vars.cardname_e) | local related_set = relatedquery(vars.cardname_e) | ||
map( | map(related_set, function(item) | ||
item['Text'] = item['Text']:gsub('this card', "'''"..vars.cardname_e.."'''") | item['Text'] = item['Text']:gsub('this card', "'''"..vars.cardname_e.."'''") | ||
item['Cards'] = get_related_cards(frame.args.cardname, item) | item['Cards'] = get_related_cards(frame.args.cardname, item) | ||
return item | return item | ||
end) | end) | ||
for _,row in pairs(related_set) do | |||
for row in related_set do | |||
if row['Cards']~=nil and string.len(row['Cards'])>0 then | if row['Cards']~=nil and string.len(row['Cards'])>0 then | ||
append(vars.related, row) | append(vars.related, row) | ||
Line 426: | Line 428: | ||
text = stache(templates.template_base, vars):gsub('\n','') | text = stache(templates.template_base, vars):gsub('\n','') | ||
text = frame:preprocess(text) | if(frame.args.debug==nil) then | ||
text = frame:preprocess(text) | |||
end | |||
text = dewikitext(text) | text = dewikitext(text) | ||
return text | return text |