@iyulab/template-binding
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

template-binding

Install

NPM

npm install @iyulab/template-binding

How to use

import { bind } from '@iyulab/template-binding';

const props = {
  innerText: "{{title}}",
  style: { "background": "{{color}}" }
};
const data = {
  title: "hello",
  color: "red"
};

bind.binding({
  target: this.header, // h1, div, DOM-element, anything...
  props: props,
  data: data
});

Use Expression Syntax

This library uses the JSONata expression syntax. See https://docs.jsonata.org/overview.html

Observable

object to an Observable object with a callback function.

import { observable } from '@iyulab/template-binding';

function onChangedValue(data: any, onChangedValue: any): any {
  console.log('onChangedValue', data, onChangedValue);
}

const data = {
  title: "hello"
};
observable(data, onChangedValue);

data.title = "world";

Log

onChangedValue {title: 'world'}title: "world"[[Prototype]]: Object {property: 'title', oldValue: 'hello', value: 'world'}

And more...

See the sample site https://template-binding.github.io/

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.91latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.91
0.1.80
0.1.70
0.1.40
0.1.30
0.1.20
0.1.11
0.1.00
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.11

Package Sidebar

Install

npm i @iyulab/template-binding

Weekly Downloads

3

Version

0.1.9

License

MIT

Unpacked Size

14.9 kB

Total Files

6

Last publish

Collaborators

  • iyujune
  • caveman