renderplus
Advanced renderer for Express
Install
npm install renderplus
Full example
const express = const renderplus = const app = app let button1 = false let options = text: 'Zero' value: 0 text: 'One' value: 1 text: 'Two' value: 2 text: 'Three' value: 3 text: 'Four' value: 4 app app
It renders
Test SELECT A NUMBER: zero one two three four Button 1
Render method syntax
res
htmlTag
: array
Tag syntax
tagName attributes content
tagName
: stringattributes
: objectcontent
: array (children) or string (text)
attributes
andcontent
are optional
Example
'br'
'h1' 'Hello World'
'meta' charset: 'utf-8'
'div' id: 'test' 'Hello World'
'div' id: 'test' //children here
'body' //children here
Text
Example
'body' 'It is a text inside BODY' 'br' 'h1' 'It is a text inside H1' 'Here is another text inside BODY'
Conditional rendering
'if' condition then: thenContent else: elseContent
condition
: booleanthenContent
: array (tag)elseContent
: array (tag)
elseContent
is optional
List rendering
'for' list callback
list
: arraycallback
: function
Callback syntax
content
content
: array (tag)
Creating layouts and components Example
const express = const renderplus = const app = app let 'html' 'head' 'title' 'Test' 'meta' charset: 'utf-8' 'body' children let 'button' class: 'my-custom-button' label app app