Toggle search
Search
Toggle menu
notifications
Toggle personal menu
Editing
Module:Mbox
From Celestial Compass Roleplaying Wiki
Views
Read
Edit source
View history
associated-pages
Module
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local libraryUtil = require( 'libraryUtil' ) local checkType = libraryUtil.checkType local mArguments -- lazily initialise [[Module:Arguments]] local mError -- lazily initialise [[Module:Error]] local p = {} --- Helper function to throw error -- -- @param msg string - Error message -- -- @return string - Formatted error message in wikitext local function makeWikitextError( msg ) mError = require( 'Module:Error' ) return mError.error{ message = 'Error: ' .. msg .. '.' } end function p.mbox( frame ) local args = getArgs( frame ) local title = args[1] or args[ 'title' ] local text = args[2] or args[ 'text' ] if not s then return p.makeWikitextError( 'no text specified', 'Template:Mbox#Errors', args.category ) end return p._mbox( title, text, { extraclasses = args.extraclasses, icon = args.icon } ) end function p._mbox( title, text, options ) checkType( '_mbox', 1, title, 'string' ) checkType( '_mbox', 2, text, 'string' ) checkType( '_mbox', 3, options, 'table', true ) options = options or {} local mbox = mw.html.create( 'div' ) local extraclasses if type( options.extraclasses ) == 'string' then extraclasses = options.extraclasses end mbox :attr( 'role', 'presentation' ) :addClass( 'mbox' ) :addClass( extraclasses ) local mboxTitle = mbox:tag( 'div' ):addClass( 'mbox-title' ) if options.icon and type( options.icon ) == 'string' then mboxTitle:tag( 'div' ) :addClass( 'mbox-icon metadata' ) :wikitext( '[[File:' .. options.icon .. '|14px|link=]]' ) :done() :tag( 'div' ) :wikitext( title ) else mboxTitle:wikitext( title ) end mbox:tag( 'div' ) :addClass( 'mbox-text' ) :wikitext( text ) return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Module:Mbox/styles.css' } } .. tostring(mbox) end return p
Summary:
Please note that all contributions to Celestial Compass Roleplaying Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
CCRPWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Mbox/doc
(
edit
)