This is the documentation page for Module:DeclarativeUI
This is a documentation subpage for 'Module:DeclarativeUI'.
It contains usage information, categories, and other content that is not part of the original module page.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
L 55 — iterateChildren L 87 — element:render L 101 — render |
DeclarativeUI is an alternative to the existing Scribunto HTML library in the style of React's createElement.
createElement
Parameter | Description | Type | Status |
---|---|---|---|
type |
Element tag | string | required |
attributes |
Dictionary of attributes | table<string, any> | optional |
...children |
Children | element or table<element> or string | optional |
local createElement = require( 'Module:DeclarativeUI' )
-- You can create a simple element like this
createElement( 'div' ):render() -- <div/>
-- Add some attributes
createElement( 'div', { a = 'b' } ):render() -- <div a="b"/>
-- What about some text?
createElement( 'h1', nil, 'Scream!' ):render() -- <h1>Scream!</h1>
-- What about other elements?
local someElement = createElement( 'span', { style = 'color: red' }, 'Hello World' )
createElement( 'div', nil, 'This goes first', someElement ) -- <div>This goes first<span style="color: red">Hello World</span></div>
-- You can have as much children as you want
createElement( 'div', nil, 'a', 'b', 'c' ) -- <div>abc</div>