knockoutjs-parser

0.0.1 • Public • Published

knockoutjs-parser

Server-side knockoutjs templates parser

Warning!

It's realy just a proof of concept for now. Use at your own risks, but have fun!

TODO

Install

npm install knockoutjs-parser

Usage

With express

var express = require('express');
var app = express(); // express >=3.0 else: express.createServer();

// ...

var ko = require('knockoutjs-parser');
app.engine('xml', ko.__express);

// ...

app.get('/', function(req, res, next) {
    res.render('view', {
        title: 'Hello',
        text: 'World!'
    });
});

Template exemple

---
title: {category.title} :: JeanSebTr's blog
style:
 - css/some-style.css
 - css/more-style.styl
script:
 - js/jquery.js
 - js/strange-syntax.coffee
---
<block name="body">
    <header>
        <h1>JeanSebTr's blog</h1>
    </header>
    <section>
        <header>
            <h2>Category: <span data-bind="text: category.title" /></h2>
        <header>
        <!-- ko foreach: articles -->
        <article>
            <header>
                <h3 data-bind="text: title" />
                <p>Author: <span data-bind="text: author" /></p>
            </header>
            <p data-bind="text: content" />
        </article>
        <!-- /ko -->
    </section>
</block>

Template features

knockoutjs bindings

knockoutjs-parser currently implement these knockoutjs' bindings:

knockoutjs-parser will implement these knockoutjs' bindings:

knockoutjs-parser won't implement bindings related to events handling. Because events don't happen server-side...

The template binding may be implemented if there is a clean way to do it.

YAML header

A header of YAML data may be used to define additionnal variables to those passed to res.render

Views inheritance

Not yet.

Client-side ko.applyBindings

A lot to think about here...

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i knockoutjs-parser

    Weekly Downloads

    1

    Version

    0.0.1

    License

    BSD

    Last publish

    Collaborators

    • jeansebtr