2.1.0 • Published 2 years ago

fepp v2.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Functions

Typedefs

newElement(tagName, ...classList) ⇒ element

Creates an instance of Element.

Kind: global function

ParamTypeDefaultDescription
tagNamestring"div"The tag type.
...classListstringClass 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.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

ParamTypeDescription
titlestringTitle 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

ParamType
functionfunction
...argumentsany

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

ParamType
stylesobject | 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

ParamTypeDefaultDescription
minifyboolfalseIf 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

ParamTypeDefaultDescription
minifyboolfalseIf 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.addClass(...classList) ⇒ Element

Identical to Element.classList.add but returns the {Element}

Kind: instance method of element
See: Element.classList.add

ParamTypeDescription
...classListstringClass 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

ParamTypeDescription
...classListstringClass 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

ParamTypeDescription
...classListstringClass 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

ParamTypeDescription
htmlstringHTML 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

ParamTypeDefault
namestring
valuestring"\"\""

element.setId(id) ⇒ Element

Identical to Element.id = id but returns the {Element}

Kind: instance method of element
See: Element.id = id

ParamType
idstring

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

ParamType
srcstring

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

ParamType
typestring

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

ParamType
valuestring

element.Append(...elements) ⇒ Element

Identical to Element.append but returns the {Element}

Kind: instance method of element
See: Element.append

ParamType
...elementsElement

element.Prepend(...elements) ⇒ Element

Identical to Element.prepend but returns the {Element}

Kind: instance method of element
See: Element.prepend

ParamType
...elementsElement

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

ParamType
functionfunction
...argumentsany

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

ParamType
stylesobject | 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"
});