Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
require('strict'); localcfg=mw.loadData('Modul:Cite/config'); --[[--------------------------< S U B S T I T U T E >---------------------------------------------------------- Substitutes $1, $2, etc in <message> with data from <data_t>. Returns plain-text substituted string when <data_t> not nil; returns <message> else. ]] localfunctionsubstitute(message,data_t) returndata_tandmw.message.newRawMessage(message,data_t):plain()ormessage; end --[[--------------------------< M A K E _ E R R O R _ M S G >-------------------------------------------------- Assembles an error message from module name, message text, help link, and error category. ]] localfunctionmake_error_msg(frame,msg) localmodule_name=frame:getTitle();-- get the module name for prefix and help-link label localnamespace=mw.title.getCurrentTitle().namespace;-- used for categorization localcategory_link=(0==namespace)andsubstitute('[[Category:$1]]',{cfg.settings_t.err_category})or''; returnsubstitute('<span style="color:#d33">Error: {{[[$1|#invoke:$2]]}}: $3 ([[:$4|$5]])</span>$6', { module_name,-- the module name with namespace module_name:gsub('Modul:',''),-- the module name without namespace msg,-- the error message cfg.settings_t.help_text_link,-- help wikilink to text at help page cfg.settings_t.help,-- help wikilink display text category_link-- link to error category (for main namespace errors only) }) end --[[--------------------------< C I T E >--------------------------------------------------------------------- Function to call Module:Citation/CS1/sandbox with appropriate parameters. For use when an article exceeds the post-expand include size limit. {{#invoke:cite|book|title=Title}} ]] localfunctioncite(frame,template) localargs_t=require('Modul:Arguments').getArgs(frame,{frameOnly=true}); template=template:lower();-- lowercase for table indexes ifnotcfg.known_templates_t[template]then-- do we recognize this template name? returnmake_error_msg(frame,substitute(cfg.settings_t.unknown_name,{template}));-- nope; abandon with error message end localconfig_t={['CitationClass']=cfg.citation_classes_t[template]ortemplate};-- set CitationClass value returnrequire('Modul:Citation/CS1')._citation(nil,args_t,config_t);-- go render the citation end --[[--------------------------< E X P O R T S >--------------------------------------------------------------- ]] localp={}; localfunctionindex(_,template)-- This function gets called by the metatable as index(table, key) returnfunction(frame)returncite(frame,template)end;-- Return a function which calls cite() with the key name end localmetatable={['__index']=index}-- Set __index, which is returned if table[key] is nil, to the index function setmetatable(p,metatable)-- Assign the metatable to the returned table returnp