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:Element
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:Element
require( 'strict' ) local element = mw.loadJsonData( 'Module:Element/Element.json' ) local p = {} --- Get the element id --- --- @param elementName string --- @return string local function getElementId( elementName ) return elementName:lower() end --- Render the element badge --- --- @param elementId string --- @param elementData table --- @return string local function renderElement( elementId, elementData ) local badge = require( 'Module:BadgeLua' ) return badge.render( { icon = elementData.icon, text = elementData.name, link = elementData.page or elementData.name, class = 't-element t-element--' .. elementId } ) 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 )[1] ) end --- Render the rarity badge --- --- @param elementName string --- @return string function p._main( elementName ) local elementId = getElementId( elementName ) local elementData = element[elementId] if not elementData then error( 'Invalid element name: ' .. elementName ) end return mw.getCurrentFrame():extensionTag { name = 'templatestyles', args = { src = 'Module:Element/styles.css' } } .. renderElement( elementId, elementData ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:Element/doc
(
view source
)
Return to
Module:Element
.