https://github.com/tenphi/jml
Data-driven content generation library
https://github.com/tenphi/jml
Last synced: about 1 year ago
JSON representation
Data-driven content generation library
- Host: GitHub
- URL: https://github.com/tenphi/jml
- Owner: tenphi
- License: mit
- Created: 2012-03-22T17:47:27.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2013-08-04T11:19:51.000Z (almost 13 years ago)
- Last Synced: 2025-03-25T22:01:34.812Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 113 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
JML
===
Data-driven content generation library
## Getting started
Install via NPM...
```
$ npm install jml
```
... or add script to your web page.
```html
```
... or install script via bower and add via requirejs.
```bash
bower install git://github.com/tenphi/jml.git
```
```javascript
require(['./components/jml/jml'], function(jml) {
jml.render(/* view *//*, state */);
});
```
## Simple usage
```javascript
jml.render([
['div',
{ class: 'container' },
['a', {
class: 'link',
href: 'http://tenphi.me'
}, 'Link text'],
['img', {
src: '/myphoto.jpg',
alt: '',
style: {
width: '100px'
}
}]
]
]);
```
output:
```html
```
### Render with state
Create template:
```javascript
var link = jml.view([
['a', {
href: 'http://tenphi.me',
target: function() {
return this.target;
}
}, function() {
return this.body;
}]
]);
```
and render it with state:
```javascript
link({
body: 'text',
target: '_blank'
});
```
output:
```html
text
```