Giter Site home page Giter Site logo

knockoutjs-parser's Introduction

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...

knockoutjs-parser's People

Contributors

jeansebtr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.