README
Synthes
How to start?
npm i synthes --save
import Synthes from './synthes';
or
let Synthes = require('./synthes');
or
<script src="synthes.js"></script>
JSON template:
let template = {
"span": {
"class": 'some your class',
"attribute": 'some your attribute',
"content": 'Hello Synthes!'
}
}
And lets do Synthes:
let sandbox = document.querySelectorAll('some selector')[0]; // Choose your sandbox
let synthes = Synthes(template, sandbox); // Creating Synthes object
synthes.render(); // rendering our template into sandbox
Simple, but maybe without object? Ok..
let sandbox = document.querySelectorAll('some selector'); // Choose your sandbox
Synthes(template, sandbox).render(); // rendering
Ok. Without sandbox..
document.body.appendChild( Synthes(template).node ); // I think u understand
What about simple Synthes object?
let a = Synthes();
a.node - our template as DOM Node
a.string - our DOM Node as string
a.isSynthes - always true if its a Synthes object
a.template - JSON template
a.bind(s) - to bind sandbox "s"
a.render() - to render template into sandbox
What about template?
let template = {
'node': { //Your DOM Node
'attribute': 'attribute value',
'attribute2': 'attribute2 value',
...,
'content': 'some string content' //May be a string, a node or a array template
}
};
What about mixed template?
let template = {
'node': { //Your DOM Node
'attribute': 'attribute value',
'attribute2': 'attribute2 value',
...,
'$span': 'some string content'
}
};
U can see "