wegine
v0.1.1
Published
A functional dom-based template engine.
Downloads
1
Maintainers
Readme
wegine
A simple, lightweight, beautiful and easy-to-use universal template engine.
How to use
First, it only have two file:
- element.ts.
It defined a
Base
abstract class and aElement
instance class.
Base
.Base
implements the basic interface that an html element should have. Such as child elements, attributes, events, styles, etc.Element
.Element
extendsBase
, it renders the data in Base into a real dom node.
- utils.ts. Some useful functions are defined in there to facilitate you to quickly create templates.
API
For more, please visit src/element.ts
and src/utils.ts
files.
Here are some commonly used APIs:
class Element(type: keyof HTMLElementTagNameMap)
All method support chain-calls.attr(attr: Attributes)
Append attributes to your element.id(id: string)
function h(type: keyof HTMLElementTagNameMap): Element
Create element withElement
.function use(type: keyof HTMLElementTagNameMap): ElementCreator
Shortcut to define h(...).
License
GPL-3.0.