Show:
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
(static) element(name, attrsopt, contentsopt) → {string}
...
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
(static) escape(s) → {string}
...
Escape a string for HTML.
Converts special characters to HTML entities.
mw.html.escape( '< > \' & "' );
// Returns < > ' & "
Parameters:
Name | Type | Description |
---|---|---|
s |
string | The string to escape |
- Source:
Returns:
HTML
- Type
- string