HTML construction helper functions.
- Source:
Example
var Html, output;
Html = mw.html;
output = Html.element( 'div', {}, new Html.Raw(
Html.element( 'img', { src: '<' } )
) );
mw.log( output ); // <div><img src="<"/></div>
Classes
Methods
element(name, attrsopt, contentsopt) → {string}static
#
Create an HTML element string, with safe escaping.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | The tag name. |
||
attrs |
Object |
<optional> |
An object with members mapping element names to values |
|
contents |
string
|
mw.html.Raw
|
null
|
<optional> |
null | The contents of the element.
|
- Source:
Returns:
HTML
- Type
- string
Create an HTML element string, with safe escaping.
escape(s) → {string}static
#
Escape a string for HTML.
Converts special characters to HTML entities.
Example
mw.html.escape( '< > \' & "' );
// Returns < > ' & "
Parameters:
Name | Type | Description |
---|---|---|
s |
string | The string to escape |
- Source:
Returns:
HTML
- Type
- string
Escape a string for HTML.