jeml-example

0.0.1 • Public • Published

jeml-example

Installation

$ npm install jeml-example

example

in layout.jeml:

default (title, body) {
    html: {
        head: {
            title: `title`
            script(src="some_address...")
        }
        body: {
            `body`
        }
    }
}

in view.jeml:

import layout "./layout" // import default mixin from layout.jeml
 
default {
    % var title = "I am title";
    `layout(title, body())`
}
 
mixin body {
    p: "I am body"
 
    % var users = {
    %     "foo": "I am foo",
    %     "bar": "I am bar"
    % }
 
    for name: introduction in `users` {
        p: { "name: " `name`}
        p: { "introduce: " `introduction`}
    }
}
 
export print_name (name{
    p: { "my name is " `name}
}

in main.js:

// you need to compile *.jeml file to *.js file before `require`
var view = require('jeml-example');
var beautify = require('js-beautify').html;
 
console.log(beautify(view()));
console.log(beautify(view.print_name("Gyson")));
/* output:
<html>
 
<head>
    <title>I am title</title>
    <script src="some_address..."></script>
</head>
 
<body>
    <p>I am body</p>
    <p>name: foo</p>
    <p>introduce: I am foo</p>
    <p>name: bar</p>
    <p>introduce: I am bar</p>
</body>
 
</html>
*/
 
console.log(view.print_name("Gyson"));
/* output:
<p>my name is Gyson</p>
*/
 

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    1

Package Sidebar

Install

npm i jeml-example

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • gyson