Skip to content

Commit

Permalink
nTPL => ntpl
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Dec 28, 2010
1 parent 7bc951a commit 80b46e0
Show file tree
Hide file tree
Showing 54 changed files with 201 additions and 201 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ build:
install:
@echo "Installing..."
@mkdir -p $(LIB_PREFIX)
@cp -fr lib/nTPL/* $(LIB_PREFIX)/
@cp -fr lib/ntpl/* $(LIB_PREFIX)/

uninstall:
@echo "Uninstalling ..."
@rm -f $(LIB_PREFIX)/nTPL.js
@rm -f $(LIB_PREFIX)/nTPL.native.node
@rm -f $(LIB_PREFIX)/nTPL.block.js
@rm -f $(LIB_PREFIX)/nTPL.filter.js
@rm -f $(LIB_PREFIX)/ntpl.js
@rm -f $(LIB_PREFIX)/ntpl.native.node
@rm -f $(LIB_PREFIX)/ntpl.block.js
@rm -f $(LIB_PREFIX)/ntpl.filter.js

test:
@echo "Testing..."
Expand Down
66 changes: 33 additions & 33 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
==nTPL project: simple, fast and powerfull templates for node.js (http://github.com/donnerjack13589/nTPL).
==ntpl project: simple, fast and powerfull templates for node.js (http://github.com/donnerjack13589/ntpl).
It's easy to learn - start now!
Now comes with support of <b>Express.js</b>!

==It's fast:
Mustache saids that running complex.html example gives following results:
Mu - 40 secs (benchmarks/million_complex.js)

On my PC - running nTPL's:
nTPL - 6 secs (benchmarks/million_complex.js)
On my PC - running ntpl's:
ntpl - 6 secs (benchmarks/million_complex.js)

Feel the difference?

==Some features:
* nTPL have native parser written on C++, so templates are compiled very fast.
* nTPL have many optimizations in template rendering process.
* nTPL uses buffers
* nTPL is extendable (nTPL.modificators)
* nTPL can reload template on file change (watch: true)
* ntpl have native parser written on C++, so templates are compiled very fast.
* ntpl have many optimizations in template rendering process.
* ntpl uses buffers
* ntpl is extendable (ntpl.modificators)
* ntpl can reload template on file change (watch: true)

==Installation:
npm install nTPL
npm install ntpl

==Manual installation instructions:
curl http://github.com/donnerjack13589/nTPL/raw/master/install.sh | sh
curl http://github.com/donnerjack13589/ntpl/raw/master/install.sh | sh
or if it dies "Permission Denied" or EACCESS error
curl http://github.com/donnerjack13589/nTPL/raw/master/install.sh | sudo sh
curl http://github.com/donnerjack13589/ntpl/raw/master/install.sh | sudo sh

==Advanced installation instructions:
git clone git@github.com:donnerjack13589/nTPL.git
cd nTPL
git clone git@github.com:donnerjack13589/ntpl.git
cd ntpl
make all
make test

==Basic examples:
var nTPL = require("nTPL").plugins("nTPL.block", "nTPL.filter").nTPL;
var ntpl = require("ntpl").plugins("ntpl.block", "ntpl.filter").ntpl;

nTPL("1 + 1 = {%= 1+1 %}")();
nTPL({
ntpl("1 + 1 = {%= 1+1 %}")();
ntpl({
template : "1 + 1 = {%= 1+1 %}"
})();
nTPL("filename.tpl")();
ntpl("filename.tpl")();
// 1 + 1 = 2

nTPL({
ntpl({
template : "Hello {%= a %}!",
args: ["a"]
})({a: 'World'});
// >> Hello World!

nTPL({
ntpl({
template: "Hello {%each a%}{%= this %}, {%/each%}world!",
args: ["a"]
})({a: ['Andy','Alex']});
// >> Hello Andy, Alex, World!

nTPL({
ntpl({
template: "{%if godmode%}My Lord!{%else%}Who are you?{%/if%}",
args: ["godmode"]
})({godmode: true});
// >> My Lord!

var $ = require("nTPL");
var $ = require("ntpl");
$.parse("It also works!")();
// >> It also works!

==Medium examples:

nTPL("foo {* text here won't be compiled or printed *} bar")();
ntpl("foo {* text here won't be compiled or printed *} bar")();
// >> foo bar

nTPL("{%each [1,2,3] %} "{%= this %}" {%/each%}?")();
ntpl("{%each [1,2,3] %} "{%= this %}" {%/each%}?")();
// >> "1" "2" "3"

nTPL("{%catch var a %}What's up, dude?{%/catch%}{%= a.substr(0,9) %}?")();
ntpl("{%catch var a %}What's up, dude?{%/catch%}{%= a.substr(0,9) %}?")();
// >> What's up?

nTPL({
ntpl({
template: "filename.tpl",
callback: function (tpl) {
console.log(tpl());
Expand All @@ -85,15 +85,15 @@ or if it dies "Permission Denied" or EACCESS error

==Harder examples:

nTPL({
ntpl({
template: "<button>{%= value%}</button>",
args: ["value"],
name: "input"
});
nTPL("input")({value:'Hello world!'});
ntpl("input")({value:'Hello world!'});
// >> Button with text "Hello world!"

nTPL({
ntpl({
template: "filename.tpl",
callback: function (tpl) {
console.log(tpl());
Expand All @@ -106,14 +106,14 @@ or if it dies "Permission Denied" or EACCESS error

==Block module

var nTPL = require("nTPL").plugins("nTPL.block").nTPL;
var ntpl = require("ntpl").plugins("ntpl.block").ntpl;

nTPL({
ntpl({
template: "Hello, {%block 'username'%}{%/block%}!{%= message %}",
args: ["message"],
name: "block-test"
});
nTPL("{%extends 'block-test', {message: "How do you do?"}%}{%block 'username'%}Admin{%/block%}")();
ntpl("{%extends 'block-test', {message: "How do you do?"}%}{%block 'username'%}Admin{%/block%}")();
// >> Hello, Admin!How do you do?

==Set modificators
Expand All @@ -132,8 +132,8 @@ Use "set" modificator to setup options inside template

Template generated from this file will have 'first template' name and can get 'a1', 'a2', 'a3' as arguments

var tpl = nTPL("set.html");
nTPL("first template")({a1:1,a2:2,a3:3});
var tpl = ntpl("set.html");
ntpl("first template")({a1:1,a2:2,a3:3});
tpl.options; // {name: "first template", args: ["a1", "a2", "a3"], some: "123", foo : { bar: ["1","2","3"] } }

===More info:
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/million_complex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var nTPL = require("nTPL").nTPL;
var ntpl = require("ntpl").ntpl;

var tpl = nTPL({
var tpl = ntpl({
template: "./million_complex.html",
args: ["header", "list"]
});
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var fs = require("fs");
var path = require("path");
var test = require("assert");

var nTPL = require("nTPL").plugins("nTPL.block", "nTPL.filter").nTPL;
var ntpl = require("ntpl").plugins("ntpl.block", "ntpl.filter").ntpl;

var tests = [];

Expand All @@ -21,7 +21,7 @@ console.log("q=" + q);

for (var i = 1, len = tests.length; i<len;i++) {
start = +new Date;
tests[i].run(nTPL);
tests[i].run(ntpl);
total += +new Date - start;
}

Expand Down
6 changes: 3 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var nTPL = require("nTPL").plugins('nTPL.block', 'nTPL.filter').nTPL;
var ntpl = require("ntpl").plugins('ntpl.block', 'ntpl.filter').ntpl;

var base = nTPL({
var base = ntpl({
template: "./tpl/base.html",
watch: true
});

var home = nTPL({
var home = ntpl({
template: "./tpl/index.html",
watch: true
});
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mkdir -p /tmp/nTPL && cd /tmp/nTPL && curl -# -L http://github.com/donnerjack13589/nTPL/tarball/master | tar xz --strip 1 && make && make install && echo "Installation complete"
mkdir -p /tmp/ntpl && cd /tmp/ntpl && curl -# -L http://github.com/donnerjack13589/ntpl/tarball/master | tar xz --strip 1 && make && make install && echo "Installation complete"
8 changes: 4 additions & 4 deletions lib/nTPL/nTPL.block.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**@preserve
nTPL block plugin v.0.0.2;
ntpl block plugin v.0.0.2;
Copyright 2010, Fedor Indutny;
Released under MIT license
**/
/**
* Initialize plugin
* @param {object} $ nTPL object.
* @param {object} $ ntpl object.
*/
exports.init = function($) {
// Check if nTPL is included
// Check if ntpl is included
if (!$) {
console.log('require nTPL first!');
console.log('require ntpl first!');
return;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/nTPL/nTPL.filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* @return {undefined} nothing.
*/
exports.init = function($) {
// Check if nTPL is included
// Check if ntpl is included
if (!$) {
console.log('require nTPL first!');
console.log('require ntpl first!');
return;
}

Expand Down
Loading

0 comments on commit 80b46e0

Please sign in to comment.