Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:DeclarativeUI/doc

From the Star Citizen Wiki, the fidelity™ encyclopedia

This is the documentation page for Module:DeclarativeUI

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>
Heya! We only use cookie to make the site function and save your preferences, nothing else :)