knockoutjs-parser

Server-side knockoutjs templates parser

knockoutjs-parser

Server-side knockoutjs templates parser

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

npm install knockoutjs-parser

 
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(reqresnext) {
    res.render('view', {
        title: 'Hello',
        text: 'World!'
    });
});
 
---
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>

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.

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

Not yet.

A lot to think about here...