Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Side box

From Simple English Wikipedia, the free encyclopedia
Ready for useThis module is rated asready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved bysandbox testing rather than repeated trial-and-error editing.
ProtectedThis module issubject to page protection. It is ahighly visible module in use by a very large number of pages, or issubstituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it isprotected from editing.

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

Usage from wikitext

[change source]

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

[change source]

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.



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://simple.wikipedia.org/w/index.php?title=Module:Side_box&oldid=8623280"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp