fepp v2.1.0
Functions
Typedefs
newElement(tagName, ...classList) ⇒ element
Creates an instance of Element.
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
tagName | string | "div" | The tag type. |
...classList | string | Class to apply to element. |
newDocument() ⇒ document
Creates an instance of Document. Ran once at setup, creating the exported document variable
Kind: global function
document : external:document
The document class from jsdom.
Kind: global typedef
See: document
- document : external:document
- .setTitle(title) ⇒ string
- .clearDocument() ⇒ document
- .addJs(function, [...arguments]) ⇒ Element
- .addCss(styles) ⇒ document
- .renderJs([minify]) ⇒ string | Promise.<string>
- .renderCss([minify]) ⇒ string
- .render() ⇒ string
document.setTitle(title) ⇒ string
Sets the title of the document.
Kind: instance method of document
Returns: string - The HTML DOM string of the title element that was put in the document
Param | Type | Description |
---|---|---|
title | string | Title to apply to the document. |
document.clearDocument() ⇒ document
Replaces the main document with a new one.
Kind: instance method of document
document.addJs(function, ...arguments) ⇒ Element
Add a JavaScript snippet to the rendered document. The snippets will only be ran at client. The function must be anonymous where the arguments are the arguments provided in this call. Objects will be JSON stringified while all other argumnets will be stringified with their .toString() method.
Kind: instance method of document
Param | Type |
---|---|
function | function |
...arguments | any |
Example (Log "Hello World" to the console)
document.addJs(() => console.log("Hello World"));
Example (Pass local server-side variables)
const num = 5;
document.addJs(n => console.log(n), num);
document.addCss(styles) ⇒ document
Add a CSS snippet to the rendered document. If styles is a string, it will be added to the stylesheet as it is If styles is an object, it will be handled as if every key is a selector with the value as an object where every key is a property with the value as a value.
Kind: instance method of document
Param | Type |
---|---|
styles | object | string |
Example (Usage with string)
element.addCss(`
h1 {
font-size: 2em;
border-radius: 5px;
}
`);
Example (Usage with object)
element.addCss({
"h1": {
"font-size": "2em",
"border-radius": "5px"
}
});
document.renderJs(minify) ⇒ string | Promise.<string>
Renders all JavaScript added to the document.
Kind: instance method of document
Returns: string | Promise.<string> - the JS code. Returns a {Promise} if minify is true
Param | Type | Default | Description |
---|---|---|---|
minify | bool | false | If the code should be minified |
document.renderCss(minify) ⇒ string
Renders all CSS added to the document.
Kind: instance method of document
Returns: string - the CSS code
Param | Type | Default | Description |
---|---|---|---|
minify | bool | false | If the code should be minified |
document.render() ⇒ string
Applies all styles and scripts and returns the HTML string of the document.
Kind: instance method of document
Returns: string - the HTML page
element : external:element
The element class from jsdom.
Kind: global typedef
See
- element : external:element
- .addClass(...classList) ⇒ Element
- .setClass(...classList) ⇒ Element
- .removeClass(...classList) ⇒ Element
- .setHTML(html) ⇒ Element
- .addAttribute(name, [value]) ⇒ Element
- .setId(id) ⇒ Element
- .setSrc(src) ⇒ Element
- .setType(type) ⇒ Element
- .setValue(value) ⇒ Element
- .Append(...elements) ⇒ Element
- .Prepend(...elements) ⇒ Element
- .addJs(function, [...arguments]) ⇒ Element
- .addCss(styles) ⇒ Element
element.addClass(...classList) ⇒ Element
Identical to Element.classList.add but returns the {Element}
Kind: instance method of element
See: Element.classList.add
Param | Type | Description |
---|---|---|
...classList | string | Class to apply to element. |
element.setClass(...classList) ⇒ Element
Adds one or more classes to the element after removing all previous classes.
Kind: instance method of element
Param | Type | Description |
---|---|---|
...classList | string | Class to apply to element. |
element.removeClass(...classList) ⇒ Element
Identical to Element.classList.remove but returns the {Element}
Kind: instance method of element
See: Element.classList.remove
Param | Type | Description |
---|---|---|
...classList | string | Class to remove from element. |
element.setHTML(html) ⇒ Element
Identical to Element.innerHTML = html but returns the {Element}
Kind: instance method of element
See: Element.innerHTML = html
Param | Type | Description |
---|---|---|
html | string | HTML markup to set as the innerHTML of the element |
element.addAttribute(name, value) ⇒ Element
Identical to Element.setAttribute but returns the {Element}
Kind: instance method of element
See: Element.setAttribute
Param | Type | Default |
---|---|---|
name | string | |
value | string | "\"\"" |
element.setId(id) ⇒ Element
Identical to Element.id = id but returns the {Element}
Kind: instance method of element
See: Element.id = id
Param | Type |
---|---|
id | string |
element.setSrc(src) ⇒ Element
Identical to Element.src = src but returns the {Element} and also more reliable
Kind: instance method of element
See: Element.src = src
Param | Type |
---|---|
src | string |
element.setType(type) ⇒ Element
Identical to Element.type = type but returns the {Element} and also more reliable
Kind: instance method of element
See: Element.type = type
Param | Type |
---|---|
type | string |
element.setValue(value) ⇒ Element
Identical to Element.value = value but returns the {Element} and also more reliable
Kind: instance method of element
See: Element.value = value
Param | Type |
---|---|
value | string |
element.Append(...elements) ⇒ Element
Identical to Element.append but returns the {Element}
Kind: instance method of element
See: Element.append
Param | Type |
---|---|
...elements | Element |
element.Prepend(...elements) ⇒ Element
Identical to Element.prepend but returns the {Element}
Kind: instance method of element
See: Element.prepend
Param | Type |
---|---|
...elements | Element |
element.addJs(function, ...arguments) ⇒ Element
Add a JavaScript snippet to the rendered document. The snippets will only be ran at client. The function must be anonymous where the first argument is the element and the rest is the arguments provided in this call. Objects will be JSON stringified while all other argumnets will be stringified with their .toString() method.
Kind: instance method of element
Param | Type |
---|---|
function | function |
...arguments | any |
Example (Log the elements inner text to the console)
element.addJs((el) => console.log(el.innerText));
Example (Pass local server-side variables)
const num = 5;
element.addJs((el, n) => el.innerHTML = n, num);
element.addCss(styles) ⇒ Element
Add a CSS snippet to the rendered document. If styles is a string, it will be put inside of a declaration block selecting the element If styles is an object, it will be handled as if every key is a property with the value as a value.
Kind: instance method of element
Param | Type |
---|---|
styles | object | string |
Example (Usage with string)
element.addCss(`
font-size: 2em;
border-radius: 5px;
`);
Example (Usage with object)
element.addCss({
"font-size": "2em",
"border-radius": "5px"
});