Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Side box

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Thismodule is rated asready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned onhelp pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed throughsandbox testing rather than repeated trial-and-error editing.
Page template-protectedThis module is currentlyprotected from editing.
See theprotection policy andprotection log for more details. Please discuss any changes on thetalk page; you maysubmit an edit request to ask anadministrator to make an edit if it isuncontroversial or supported byconsensus. You may alsorequest that this page be unprotected.
WarningThis Lua module is used onapproximately 1,260,000 pages, or roughly 2% of all pages.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on thetalk page before implementing them.
This module depends on the following other modules:
CSSThis module usesTemplateStyles:

This module implements the{{side box}} template.

Usage from wikitext

This module cannot be used directly from wikitext. It can only be used through the{{side box}} template. Please see the template page for documentation.

Usage from Lua modules

To use this module from other Lua modules, first load the module.

localmSideBox=require('Module:Side box')

You can then generate a side box using the _main function.

mSideBox._main(args)

Theargs variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the{{side box}} template documentation.

The abovedocumentation istranscluded fromModule:Side box/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) andtestcases(edit |run) pages.
Subpages of this module.

localyesno=require('Module:Yesno')localp={}localfunctionmakeData(args)localdata={}-- Main table classesdata.classes={}ifyesno(args.metadata)~=falsethentable.insert(data.classes,'metadata')endifargs.positionandargs.position:lower()=='left'thentable.insert(data.classes,'side-box-left')elsetable.insert(data.classes,'side-box-right')endifargs.collapsiblethentable.insert(data.classes,'mw-collapsible')ifargs.collapsible=="collapsed"thentable.insert(data.classes,'mw-collapsed')enddata.collapsible=trueendtable.insert(data.classes,args.class)-- Imageifargs.imageandargs.image~='none'thendata.image=args.imageend-- we have to check to see if a downstream use has plainlist like-- Template:Sister_project. also it's the default. wikitext is :(ifargs.textclass=='plainlist'ornotargs.textclassthendata.textclass='plainlist'data.plainlist_templatestyles='Plainlist/styles.css'elsedata.textclass=args.textclassend-- Copy over data that does not need adjustinglocalargsToCopy={-- aria qualities'role','labelledby',-- Styles'style','textstyle','templatestyles',-- Above row'above','abovestyle',-- Body row'text','imageright',-- Below row'below',}fori,keyinipairs(argsToCopy)dodata[key]=args[key]endreturndataendlocalfunctionrenderSidebox(data)-- Renders the sidebox HTML.-- Table rootlocalroot=mw.html.create('div')root:attr('role',data.role):attr('aria-labelledby',data.labelledby):addClass('side-box')fori,classinipairs(data.classesor{})doroot:addClass(class)endifdata.stylethenroot:cssText(data.style)endlocalframe=mw.getCurrentFrame()ifdata.plainlist_templatestylesthenroot:wikitext(frame:extensionTag{name='templatestyles',args={src=data.plainlist_templatestyles}})end-- The "above" rowifdata.abovethenlocalabove=root:newline():tag('div')above:addClass('side-box-abovebelow'):newline():wikitext(data.above)ifdata.textstylethenabove:cssText(data.textstyle)endifdata.abovestylethenabove:cssText(data.abovestyle)endend-- The body rowlocalbody=root:newline():tag('div')body:addClass('side-box-flex'):addClass(data.collapsibleand'mw-collapsible-content'):newline()ifdata.imagethenbody:tag('div'):addClass('side-box-image'):wikitext(data.image)endlocaltext=body:newline():tag('div')text:addClass('side-box-text'):addClass(data.textclass)ifdata.textstylethentext:cssText(data.textstyle)endtext:wikitext(data.text)ifdata.imagerightthenbody:newline():tag('div'):addClass('side-box-imageright'):wikitext(data.imageright)end-- The below rowifdata.belowthenlocalbelow=root:newline():tag('div')below:addClass('side-box-abovebelow'):wikitext(data.below)ifdata.textstylethenbelow:cssText(data.textstyle)endendroot:newline()localtemplatestyles=''ifdata.templatestylesthentemplatestyles=frame:extensionTag{name='templatestyles',args={src=data.templatestyles}}endreturnframe:extensionTag{name='templatestyles',args={src='Module:Side box/styles.css'}}..templatestyles..tostring(root)endfunctionp._main(args)localdata=makeData(args)returnrenderSidebox(data)endfunctionp.main(frame)localorigArgs=frame:getParent().argslocalargs={}fork,vinpairs(origArgs)dov=v:match('%s*(.-)%s*$')ifv~=''thenargs[k]=vendendreturnp._main(args)endreturnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Side_box&oldid=1127149393"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp