0.3.0 • Published 7 years ago

zable v0.3.0

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
7 years ago

Zable

Write JavaScript, make HTML.

Zable is a very lightweight Express view engine that allows you to use a native JavaScript syntax to render HTML documents. This means that it allows you to use...

  • Template files
  • Custom elements
  • Functions
  • Variables
  • Modules
  • ... or whatever you like!

Installation

Using npm:

npm install --save zable

Use

In your Express application, set zable as the Express view engine, and set it to render JavaScript files in your /views folder:

app.engine('js', zable.__express);
app.set('view engine', 'js');
app.set('views', path.join(__dirname, 'views'));

In /app.js:

res.render('index', {
    lang: 'en-US',
    title: 'My Website',
    description: 'Welcome to my site',
    header: 'Hello world!'
});

In /views/index.js:

module.exports = [
    html({ lang: locals.lang },
        head({},
            title({}, locals.title),
            meta({ charset: 'UTF-8' }),
            meta({ name: 'description', content: locals.description }),
        ),
        body({ id: 'app' },
            h1(locals.header)
        )
    )
];
0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago