Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
MediaWiki help
Creopedia
Search
Search
Appearance
Log in
Personal tools
Log in
View source for Module:IconText
Module
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
←
Module:IconText
require( 'strict' ) local p = {} --- @param args table --- @return table local function getProps( args ) return { icon = args.icon, iconTitle = args.iconTitle, text = args.text or args[1], size = args.size or '20px', class = args.class or '' } end --- @param icon string --- @param size string --- @return string local function getIconWikitext( icon, size ) return string.format( '[[File:%s|%s|link=|class=metadata]]', icon, size ) end --- Render the icon link --- --- @param args table --- @return mw.html local function getIconTextHtml( args ) local root = mw.html.create( 'span' ) root :addClass( 't-icon-text' ) :addClass( args.class ) root:tag( 'span' ) :addClass( 't-icon-text__icon' ) :wikitext( getIconWikitext( args.icon, args.size ) ) root:tag( 'span' ) :addClass( 't-icon-text__text' ) :wikitext( args.text ) return root end --- Wikitext entry point for the module --- --- @param frame mw.frame --- @return string function p.main( frame ) local getArgs = require( 'Module:Arguments' ).getArgs return p._main( getArgs( frame ) ) end --- Render the icon text --- --- @param args table --- @return string function p._main( args ) local props = getProps( args ) if not props.icon then error( 'No icon provided' ) end if not props.text then error( 'No text provided' ) end return mw.getCurrentFrame():extensionTag { name = 'templatestyles', args = { src = 'Module:IconText/styles.css' } } .. tostring( getIconTextHtml( props ) ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:IconText/doc
(
view source
)
Return to
Module:IconText
.