0.0.3 • Published 9 years ago

nging v0.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

Examples:

var app = require("express")();
var nging = require("nging");

function Comment() {
    this.jml = function() {
        return ["div",{className:"comment"},
                    ["h2",{className:"commentAuthor", style:this.props.style},
                        this.props.author
                    ]
               ].concat(this.props.nodes);
    };
}

function CommentList() {
    this.jml = function() {
        var commentNodes = this.props.data.map(function (comment) {
          return [Comment, {author:comment.author}, comment.text];
        });

        return ["div", {className:"commentList"}].concat(commentNodes);
    };
}

var comments = [
  {"author": "Pete Hunt", "text": "This is one comment"},
  {"author": "Jordan Walke", "text": "This is *another* comment"}
];

var jml1 = ["div",{class:"yes"},["p",{style:"color:red"},"Hello!!!",["img",{src:"http://i.imgur.com/gEZsVCW.png",width:500}]]];
var jml2 = ["html",["body",["div","dfe"],["span","ddd"]]];

var jml3 = [Comment, {author:"John", style:"color:red"}, "Hello!"];

var jml4 = ["html",jml3,jml3,jml3,jml3,jml3,jml3,jml3];

var jml5 =["form",{className:"commentForm", onSubmit:"this.handleSubmit"},
            ["input", {type:"text", placeholder:"Your name", ref:"author"}],
            ["input", {type:"text", placeholder:"Say something...", ref:"text"}],
            ["input", {type:"submit", value:"Post"}]
        ];

var jml6 =[CommentList, {data:comments}];

var jml7 = ["html", jml1,jml2,jml3,jml4,jml5];

app.get("/", function(req, res) {
    res.send(nging.render(jml7));
});

app.listen(8080);