0.6.0 • Published 11 years ago

jml v0.6.0

Weekly downloads
47
License
-
Repository
github
Last release
11 years ago

JML

Data-driven content generation library

Getting started

Install via NPM...

$ npm install jml

... or add script to your web page.

<script type="text/javascript" src="/path/to/jml.js"></script>

... or install script via bower and add via requirejs.

bower install git://github.com/tenphi/jml.git
require(['./components/jml/jml'], function(jml) {
  jml.render(/* view *//*, state */);
});

Simple usage

jml.render([
  ['div', 
    { class: 'container' },
    ['a', {
      class: 'link', 
      href: 'http://tenphi.me'
    }, 'Link text'],
    ['img', {
      src: '/myphoto.jpg', 
      alt: '', 
      style: {
        width: '100px'
      }
    }]
  ]
]);

output:

<div class="container"><a class="link" href="http://tenphi.me">Link text</a><img src="/myphoto.jpg" alt="" style="width: 100px; " /></div>

Render with state

Create template:

var link = jml.view([
  ['a', {
    href: 'http://tenphi.me',
    target: function() {
      return this.target;
    }
  }, function() {
    return this.body;
  }]
]);

and render it with state:

link({
  body: 'text',
  target: '_blank'
});

output:

<a href="http://tenphi.me" target="_blank">text</a>
0.6.0

11 years ago

0.5.3

12 years ago

0.5.2

12 years ago

0.5.1

12 years ago

0.5.0

12 years ago

0.3.8

12 years ago

0.3.7

12 years ago

0.3.6

12 years ago

0.3.5

12 years ago

0.3.3

12 years ago

0.3.2

12 years ago

0.3.0

12 years ago

0.2.5

12 years ago

0.1.0

12 years ago