@yuanliwei/binder

1.0.0 • Public • Published

binder

A simple DOM data binding tool that can be used to bind data or events to DOM elements.

View demo

  • npm install
  • npm run test

Usage

  • npm install @yuanliwei/binder
<template id="templ-code">
    <hr>
    <h1>{{title}}</h1>
    <p>{{desc}}</p>
    <code><pre>
            {{template}}
    </pre></code>
    <code><pre>
            {{code}}
    </pre></code>
</template>
import Binder from '@yuanliwei/binder'

let b = new Binder()
let templ = document.getElementById('templ-code')

b.render(templ, {
    title: 'title',
    template: templ.outerHTML,
    code: Binder.toString(),
    desc: desc,
    'h1@onclick':()=>{
        alert('click h1')
    }
})

Readme

Keywords

Package Sidebar

Install

npm i @yuanliwei/binder

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

16.2 kB

Total Files

5

Last publish

Collaborators

  • yuanliwei