"ഘടകം:InfoboxSchool" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
'local p = {} function p.getRevenueDistrict(frame) local page = frame.args.page if not page or page == '' then return '' end local title = mw.title.new(page) if not title then return '' end local content = title:getContent() if not content then return '' end -- Match Infobox School and extract "റവന്യൂ ജില്ല" local district = co...' താൾ സൃഷ്ടിച്ചിരിക്കുന്നു |
No edit summary |
||
| വരി 10: | വരി 10: | ||
if not title then | if not title then | ||
return '' | return '' | ||
end | |||
-- Follow redirect | |||
if title.isRedirect then | |||
title = title.redirectTarget | |||
if not title then | |||
return '' | |||
end | |||
end | end | ||
| വരി 17: | വരി 25: | ||
end | end | ||
-- | -- Extract Infobox School block | ||
local | local infobox = content:match('{{%s*Infobox School(.-)}}') | ||
if not infobox then | |||
return '' | |||
end | |||
-- Extract Revenue District | |||
local district = infobox:match('|%s*റവന്യൂ%s*ജില്ല%s*=%s*([^\n|}]+)') | |||
if district then | if district then | ||
return mw.text.trim(district) | |||
end | end | ||
return | return '' | ||
end | end | ||
return p | return p | ||