Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nTPL => ntpl

  • Loading branch information...
commit 80b46e0c43adc5bd6708a95703077d324b55cebe 1 parent 7bc951a
@indutny authored
Showing with 201 additions and 201 deletions.
  1. +5 −5 Makefile
  2. +33 −33 README.rdoc
  3. +2 −2 benchmarks/million_complex.js
  4. +2 −2 benchmarks/run.js
  5. +3 −3 example.js
  6. +1 −1  install.sh
  7. +4 −4 lib/nTPL/nTPL.block.js
  8. +2 −2 lib/nTPL/nTPL.filter.js
  9. +27 −27 lib/nTPL/nTPL.js
  10. +5 −5 nTPL.native/nTPL.mod.cc
  11. +1 −1  nTPL.native/nTPL.mod.h
  12. +5 −5 nTPL.native/nTPL.native.cc
  13. +2 −2 nTPL.native/nTPL.native.h
  14. +7 −7 package.json
  15. +2 −2 tests/run.js
  16. +2 −2 tests/tests/test-1.js
  17. +2 −2 tests/tests/test-10.js
  18. +2 −2 tests/tests/test-11.js
  19. +2 −2 tests/tests/test-12.js
  20. +4 −4 tests/tests/test-13.js
  21. +3 −3 tests/tests/test-14.js
  22. +4 −4 tests/tests/test-15.js
  23. +6 −6 tests/tests/test-16.js
  24. +1 −1  tests/tests/test-17.js
  25. +2 −2 tests/tests/test-18.js
  26. +2 −2 tests/tests/test-19.js
  27. +2 −2 tests/tests/test-2.js
  28. +2 −2 tests/tests/test-20.js
  29. +2 −2 tests/tests/test-21.js
  30. +2 −2 tests/tests/test-22.js
  31. +2 −2 tests/tests/test-23.js
  32. +2 −2 tests/tests/test-24.js
  33. +3 −3 tests/tests/test-25.js
  34. +2 −2 tests/tests/test-26.js
  35. +3 −3 tests/tests/test-27.js
  36. +2 −2 tests/tests/test-28.js
  37. +2 −2 tests/tests/test-29.js
  38. +2 −2 tests/tests/test-3.js
  39. +3 −3 tests/tests/test-30.js
  40. +3 −3 tests/tests/test-31.js
  41. +3 −3 tests/tests/test-32.js
  42. +3 −3 tests/tests/test-33.js
  43. +4 −4 tests/tests/test-34.js
  44. +2 −2 tests/tests/test-35.js
  45. +2 −2 tests/tests/test-36.js
  46. +2 −2 tests/tests/test-37.js
  47. +2 −2 tests/tests/test-4.js
  48. +2 −2 tests/tests/test-5.js
  49. +2 −2 tests/tests/test-6.js
  50. +2 −2 tests/tests/test-7.js
  51. +2 −2 tests/tests/test-8.js
  52. +2 −2 tests/tests/test-9.js
  53. +1 −1  tpl/index.html
  54. +9 −9 wscript
View
10 Makefile
@@ -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..."
View
66 README.rdoc
@@ -1,4 +1,4 @@
-==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>!
@@ -6,76 +6,76 @@ Now comes with support of <b>Express.js</b>!
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());
@@ -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());
@@ -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
@@ -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:
View
4 benchmarks/million_complex.js
@@ -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"]
});
View
4 benchmarks/run.js
@@ -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 = [];
@@ -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;
}
View
6 example.js
@@ -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
});
View
2  install.sh
@@ -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"
View
8 lib/nTPL/nTPL.block.js
@@ -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;
}
View
4 lib/nTPL/nTPL.filter.js
@@ -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;
}
View
54 lib/nTPL/nTPL.js
@@ -1,5 +1,5 @@
/**@preserve
- nTPL v.0.4.6;
+ ntpl v.0.4.6;
Copyright 2010, Fedor Indutny;
Released under MIT license;
Parts of code derived from jQuery JavaScript Library;
@@ -8,8 +8,8 @@
/*
* Usage:
-* var nTPL = require("nTPL").nTPL;
-* nTPL({
+* var ntpl = require("ntpl").ntpl;
+* ntpl({
* template: filename or inline template (@string),
* name: template name (template will be accessible with this name)(@string),
* args: arguments list (@array),
@@ -19,30 +19,30 @@
* watchCallback: Fired on file change (@function(template function) )
* });
*
-* nTPL(...) will generate(or return previously generated) template function,
+* ntpl(...) will generate(or return previously generated) template function,
* that returns string value
*
-* Also nTPL.modificators are available
-* See nTPL.block and nTPL.filter for examples of usage
+* Also ntpl.modificators are available
+* See ntpl.block and ntpl.filter for examples of usage
*/
/**
* @param {string} $src Template source.
-* @param {object} nTPL nTPL object.
+* @param {object} ntpl ntpl object.
* @param {object} $scope namespace.
* @param {array.<string, string>} $rep replacements.
* @return {object} generated function.
*/
-function scopedEval($src, nTPL, $scope, $rep) {
+function scopedEval($src, ntpl, $scope, $rep) {
return eval($src);
}
/**
-* exports.parse holds nTPL
+* exports.parse holds ntpl
*/
(function($) {
var fs = require('fs');
var path = require('path');
- var nTPL_native = require('./nTPL.native');
+ var ntpl_native = require('./ntpl.native');
var $tab = '\t', gid = 0, rid = 0;
@@ -88,7 +88,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
// Example: {%each arr%}<div>{%=this%}</div>{%/each%}
/** @return {string} template. */
'each': function(str) {
- return 'nTPL.each(' + str + ',function($i){';
+ return 'ntpl.each(' + str + ',function($i){';
},
'/each': '});',
@@ -104,8 +104,8 @@ function scopedEval($src, nTPL, $scope, $rep) {
};
// Add native modificators
- if (nTPL_native.initModificators)
- nTPL_native.initModificators(modificators);
+ if (ntpl_native.initModificators)
+ ntpl_native.initModificators(modificators);
/**
* Watch file changes
@@ -218,7 +218,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
* @param {object.<string, *>} options Calling options.
* @return {function(object.<string, *>): string} renderer function.
*/
- var nTPL = $.nTPL = function(options) {
+ var ntpl = $.ntpl = function(options) {
// If options is string - generate template
if (typeof options === 'string')
return $main(options);
@@ -352,7 +352,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
// Preprocess template
// Go through each row
// And replace it with code
- var parsed = nTPL_native.parse(str, $.modificators, namespace, options);
+ var parsed = ntpl_native.parse(str, $.modificators, namespace, options);
// If template is not plain (with {% or %} inside) - generate function
if (hasCode = parsed &&
@@ -526,7 +526,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
}
// Imported from jQuery
- nTPL.each = $.each = function(object, callback) {
+ ntpl.each = $.each = function(object, callback) {
var name, i = 0, length = object.length;
if (length === undefined) {
@@ -545,21 +545,21 @@ function scopedEval($src, nTPL, $scope, $rep) {
return object;
}
- // Add modificators to nTPL
- nTPL.modificators = $.modificators = modificators;
+ // Add modificators to ntpl
+ ntpl.modificators = $.modificators = modificators;
/**
* Express.js possible integration
* @param {string} str "templatename@templatefile".
*/
- nTPL.render = $.render = function(str, args) {
+ ntpl.render = $.render = function(str, args) {
str = str.split('@', 2);
var cached;
return ((cached = namecache[str[0]]) ?
cached :
- nTPL({
+ ntpl({
name: str[0],
template: str[1],
watch: true
@@ -567,7 +567,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
}
// On Exit
- process.on('exit', nTPL.unwatchAll = function() {
+ process.on('exit', ntpl.unwatchAll = function() {
try {
for (var i = 0 , len = fileWatchers.length; i < len; i++)
fs.unwatchFile(fileWatchers[i]);
@@ -578,7 +578,7 @@ function scopedEval($src, nTPL, $scope, $rep) {
// Catch exceptions
process.on('uncaughtException', function(err) {
- console.log('nTPL caught exception: ' + err);
+ console.log('ntpl caught exception: ' + err);
});
@@ -587,19 +587,19 @@ function scopedEval($src, nTPL, $scope, $rep) {
* @param {string} path Path.
*/
function plugin(path) {
- if (path === 'nTPL.block' || path === 'nTPL.filter') {
+ if (path === 'ntpl.block' || path === 'ntpl.filter') {
path = './' + path;
}
var plugin = require(path);
// If it's correct plugin
- plugin.init && plugin.init(nTPL);
+ plugin.init && plugin.init(ntpl);
}
/**
* Exposed plugin install
- * nTPL.plugin('plugin1', 'plugin2');
+ * ntpl.plugin('plugin1', 'plugin2');
*/
- nTPL.plugins = $.plugins = function() {
+ ntpl.plugins = $.plugins = function() {
// If called without paths
var len;
if (!(len = arguments.length)) return;
@@ -613,5 +613,5 @@ function scopedEval($src, nTPL, $scope, $rep) {
}
})(exports);
-// Prevent any changes to nTPL
+// Prevent any changes to ntpl
Object.freeze(exports);
View
10 nTPL.native/nTPL.mod.cc
@@ -1,15 +1,15 @@
/*
-* Part of nTPL
-* nTPL.modificators v.0.1.0
+* Part of ntpl
+* ntpl.modificators v.0.1.0
* Copyright 2010, Fedor Indutny
* Released under MIT license
*/
-#include <nTPL.mod.h>
+#include <ntpl.mod.h>
#include <v8.h>
#include <stdio.h>
-namespace nTPL {
+namespace ntpl {
namespace mod {
using namespace v8;
@@ -209,7 +209,7 @@ namespace nTPL {
#define NEW_MODIFICATOR(name,func) modificators->Set( String::New(name), FunctionTemplate::New(func)->GetFunction() )
- // This function adds modificator to current nTPL instance
+ // This function adds modificator to current ntpl instance
Handle<Value> add(const Arguments& args)
{
HandleScope scope;
View
2  nTPL.native/nTPL.mod.h
@@ -1 +1 @@
-#ifndef NODE_NTPL_MODIFICATORS_MODULE
+#ifndef NODE_NTPL_MODIFICATORS_MODULE
View
10 nTPL.native/nTPL.native.cc
@@ -1,6 +1,6 @@
/*
-* Part of nTPL
-* nTPL.native v.0.3.0
+* Part of ntpl
+* ntpl.native v.0.3.0
* Copyright 2010, Fedor Indutny
* Released under MIT license
*/
@@ -8,14 +8,14 @@
#include <stdio.h> // sprintf
#include <string.h> // strlen
-#include "nTPL.mod.h"
+#include "ntpl.mod.h"
using namespace v8;
#ifdef NODE_NTPL_MODIFICATORS_MODULE
-using namespace nTPL;
+using namespace ntpl;
#endif //NODE_NTPL_MODIFICATORS_MODULE
-namespace nTPL {
+namespace ntpl {
static Persistent<String> REPLACEMENTS_SYMBOL;
static Persistent<String> REPLVARS_SYMBOL;
View
4 nTPL.native/nTPL.native.h
@@ -6,9 +6,9 @@
#include <stdio.h>
#include <stdlib.h>
-#include "nTPL_mod.h"
+#include "ntpl_mod.h"
-namespace nTPL {
+namespace ntpl {
struct Replacements_;
struct Position_;
View
14 package.json
@@ -1,20 +1,20 @@
{
- "name" : "nTPL",
- "description" : "nTPL is node.js extremely fast template engine",
- "url" : "http://github.com/donnerjack13589/nTPL",
- "keywords" : ["template", "nTPL" ,"parser"],
+ "name" : "ntpl",
+ "description" : "ntpl is node.js extremely fast template engine",
+ "url" : "http://github.com/donnerjack13589/ntpl",
+ "keywords" : ["template", "ntpl", "ntpl","parser"],
"author" : "Fedor Indutny <fedor.indutny@gmail.com>",
"contributors" : [
{name: "Fedor Indutny", email: "fedor.indutny@gmail.com"}
],
"repository": {
"type": "git",
- "url": "http://github.com/donnerjack13589/nTPL.git"
+ "url": "http://github.com/donnerjack13589/ntpl.git"
},
- "version" : "0.4.6",
+ "version" : "0.5.0",
"engines" : { "node": ">=0.1.103" },
"directories": {
- "lib": "./lib/nTPL"
+ "lib": "./lib/ntpl"
},
"scripts" :{
"preinstall" : "make build"
View
4 tests/run.js
@@ -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 = [];
@@ -50,7 +50,7 @@ function next() {
var async = false;
try {
- if (async = tests[i].run(test, nTPL, testPass)) {
+ if (async = tests[i].run(test, ntpl, testPass)) {
} else {
View
4 tests/tests/test-1.js
@@ -1,5 +1,5 @@
this.name = "Simple inline";
-this.run = function(test, nTPL) {
- var a = nTPL("test")();
+this.run = function(test, ntpl) {
+ var a = ntpl("test")();
test.equal("test", a);
}
View
4 tests/tests/test-10.js
@@ -1,6 +1,6 @@
this.name = "Each modificator";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "{%each a %}-{%= this %}={%= $i %}-{%/each%}",
args: ["a"]
})({
View
4 tests/tests/test-11.js
@@ -1,6 +1,6 @@
this.name = "Catch modificator";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "{%catch var a %}test{%/catch%}!{%= a %}!"
})();
test.equal("!test!", a);
View
4 tests/tests/test-12.js
@@ -1,6 +1,6 @@
this.name = "If-Else modificator";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "{%if true%}123{%/if%}{%if true%}456{%else%}wrong{%/if%}{%if false%}wrong{%else%}789{%/if%}"
})();
test.equal("123456789", a);
View
8 tests/tests/test-13.js
@@ -1,11 +1,11 @@
this.name = "Parser test";
-this.run = function(test, nTPL) {
- nTPL.modificators["parser-test1"] = "$p(123,$_);";
- nTPL.modificators["parser-test2"] = function (str, namespace) {
+this.run = function(test, ntpl) {
+ ntpl.modificators["parser-test1"] = "$p(123,$_);";
+ ntpl.modificators["parser-test2"] = function (str, namespace) {
return "$p('~" + str + namespace + "!',$_);";
};
- var a = nTPL({
+ var a = ntpl({
template: "{%parser-test1%}{%parser-test1 %}{%parser-test2%}{%parser-test2 123%}"
})();
View
6 tests/tests/test-14.js
@@ -1,8 +1,8 @@
this.name = "Template naming test";
-this.run = function(test, nTPL) {
- nTPL({
+this.run = function(test, ntpl) {
+ ntpl({
template: "123",
name : "a"
});
- test.equal("123", nTPL("a")());
+ test.equal("123", ntpl("a")());
}
View
8 tests/tests/test-15.js
@@ -1,13 +1,13 @@
this.name = "Template naming test";
-this.run = function(test, nTPL) {
- nTPL({
+this.run = function(test, ntpl) {
+ ntpl({
template: "123{%= a %}",
name : "a"
});
- nTPL({
+ ntpl({
template: "123{%= a %}",
name : "a",
args: ["a"]
});
- test.equal("1234", nTPL("a")({a: 4}));
+ test.equal("1234", ntpl("a")({a: 4}));
}
View
12 tests/tests/test-16.js
@@ -1,19 +1,19 @@
this.name = "Block module test";
-this.run = function(test, nTPL) {
- nTPL({
+this.run = function(test, ntpl) {
+ ntpl({
template: "{%block 'a' %}1{%/block%}2{%block 'b'%}3{%/block%}",
name : "a"
});
- var a = nTPL({
+ var a = ntpl({
template: "{%extends 'a' %}"
})();
- var b = nTPL({
+ var b = ntpl({
template: "{%extends 'a' %}{%block 'a' %}!{%/block%}"
})();
- var c = nTPL({
+ var c = ntpl({
template: "{%extends 'a' %}{%block 'b' %}!{%/block%}"
})();
- var d = nTPL({
+ var d = ntpl({
template: "{%extends 'a' %}{%block 'a' %}~{%/block%}{%block 'b' %}!{%/block%}"
})();
test.equal("123!2312!~2!", a + b + c + d);
View
2  tests/tests/test-17.js
@@ -1,5 +1,5 @@
this.name = "Async working";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
setTimeout(function(){
callback();
View
4 tests/tests/test-18.js
@@ -1,11 +1,11 @@
this.name = "Async template loading";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
var fs = require("fs");
fs.writeFile("./tests/file-18", "123", function(){
- nTPL({
+ ntpl({
template: "./tests/file-18",
callback: function (a) {
callback( a() !== "123" && {message: "Not equal : " + a()} );
View
4 tests/tests/test-19.js
@@ -1,6 +1,6 @@
this.name = "Filter module tests: escape";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%filter escape %}&^%$$#@#!)({%/filter%}")();
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%filter escape %}&^%$$#@#!)({%/filter%}")();
test.equal(a, escape("&^%$$#@#!)("));
View
4 tests/tests/test-2.js
@@ -1,6 +1,6 @@
this.name = "Simple inline (args is object)";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "test"
})();
test.equal("test", a);
View
4 tests/tests/test-20.js
@@ -1,6 +1,6 @@
this.name = "Filter module tests: upper";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%filter upper %}abc{%/filter%}")();
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%filter upper %}abc{%/filter%}")();
test.equal(a, "ABC");
View
4 tests/tests/test-21.js
@@ -1,6 +1,6 @@
this.name = "Filter module tests: upper";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%filter lower %}ABC{%/filter%}")();
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%filter lower %}ABC{%/filter%}")();
test.equal(a, "abc");
View
4 tests/tests/test-22.js
@@ -1,6 +1,6 @@
this.name = "Filter module tests: safe";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%filter safe %}<>&'\"{%/filter%}")();
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%filter safe %}<>&'\"{%/filter%}")();
test.equal(a, "&lt;&gt;&amp;&#039;&quot;");
View
4 tests/tests/test-23.js
@@ -1,11 +1,11 @@
this.name = "Async template loading";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
var fs = require("fs");
fs.writeFile("./tests/file-23", "123", function(){
- var b = nTPL({
+ var b = ntpl({
template: "./tests/file-23",
callback: function (a) {
callback( b !== "" && {message: "Not equal : " + b} );
View
4 tests/tests/test-24.js
@@ -1,7 +1,7 @@
this.name = "Parser: comments";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("You can{*'t*} see this")();
+ var a = ntpl("You can{*'t*} see this")();
test.equal(a, "You can see this");
}
View
6 tests/tests/test-25.js
@@ -1,13 +1,13 @@
this.name = "Block module: 'extends' with arguments";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL({
+ var a = ntpl({
template: "{%= a %}",
args: ["a"],
name: "a"
});
- var b = nTPL({
+ var b = ntpl({
template: "{%extends 'a', {a: 'test'} %}"
})();
View
4 tests/tests/test-26.js
@@ -1,7 +1,7 @@
this.name = "Parser: UTF16";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("абвгд{%= 'еёжз'%}")();
+ var a = ntpl("абвгд{%= 'еёжз'%}")();
test.equal(a, "абвгдеёжз");
View
6 tests/tests/test-27.js
@@ -1,8 +1,8 @@
this.name = "Native mod: set name";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set name test %}123")();
- var b = nTPL("test")();
+ var a = ntpl("{%set name test %}123")();
+ var b = ntpl("test")();
test.equal(a, b);
View
4 tests/tests/test-28.js
@@ -1,7 +1,7 @@
this.name = "Native mod: set options / one";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set args hello %}{%= hello %}")({hello: "Hello world!"});
+ var a = ntpl("{%set args hello %}{%= hello %}")({hello: "Hello world!"});
test.equal(a, "Hello world!");
View
4 tests/tests/test-29.js
@@ -1,7 +1,7 @@
this.name = "Native mod: set options / multiple";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set args arg1,arg2,arg3 %}{%= arg1 %}-{%= arg2 %}-{%= arg3 %}")({
+ var a = ntpl("{%set args arg1,arg2,arg3 %}{%= arg1 %}-{%= arg2 %}-{%= arg3 %}")({
arg1: "abc",
arg2: "def",
arg3: "ghi"
View
4 tests/tests/test-3.js
@@ -1,5 +1,5 @@
this.name = "Simple readfile";
-this.run = function(test, nTPL) {
- var a = nTPL("./tests/file-1")();
+this.run = function(test, ntpl) {
+ var a = ntpl("./tests/file-1")();
test.equal("test", a);
}
View
6 tests/tests/test-30.js
@@ -1,8 +1,8 @@
this.name = "Native mod: set name /wo space";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set name test%}123")();
- var b = nTPL("test")();
+ var a = ntpl("{%set name test%}123")();
+ var b = ntpl("test")();
test.equal(a, b);
View
6 tests/tests/test-31.js
@@ -1,8 +1,8 @@
this.name = "Native mod: set name with tabs";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set name test31 %}123")();
- var b = nTPL("test31")();
+ var a = ntpl("{%set name test31 %}123")();
+ var b = ntpl("test31")();
test.equal(a, b);
View
6 tests/tests/test-32.js
@@ -1,8 +1,8 @@
this.name = "Native mod: set name with many tabs & spaces";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set name test32 %}123")();
- var b = nTPL("test32")();
+ var a = ntpl("{%set name test32 %}123")();
+ var b = ntpl("test32")();
test.equal(a, b);
View
6 tests/tests/test-33.js
@@ -1,8 +1,8 @@
this.name = "Native parser: modificator tabs & spaces";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
- var a = nTPL("{%set name test33%}123")();
- var b = nTPL("test33")();
+ var a = ntpl("{%set name test33%}123")();
+ var b = ntpl("test33")();
test.equal(a, b);
View
8 tests/tests/test-34.js
@@ -1,18 +1,18 @@
this.name = "Express.js integration";
-this.run = function(test, nTPL, callback) {
+this.run = function(test, ntpl, callback) {
var fs = require("fs");
fs.writeFileSync("./tests/file-34", "{%set args a1,a2 %}{%= a1 %}:{%= a2 %}");
- var a = nTPL.render("express.js@./tests/file-34",{
+ var a = ntpl.render("express.js@./tests/file-34",{
a1: 1,
a2: 2
});
- var b = nTPL("express.js");
+ var b = ntpl("express.js");
b = b({
a1: 1,
a2: 2
});
- nTPL.unwatchAll();
+ ntpl.unwatchAll();
test.equal(a, "1:2");
test.equal(a, b);
View
4 tests/tests/test-35.js
@@ -1,5 +1,5 @@
this.name = "Set modificator: multivalue with inheritance";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%set a.b 1,2,3 %}").options.a.b;
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%set a.b 1,2,3 %}").options.a.b;
test.equal("1-2-3",a.join("-"));
}
View
4 tests/tests/test-36.js
@@ -1,5 +1,5 @@
this.name = "Set modificator: singleton with inheritance";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%set a.b abab %}").options.a.b;
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%set a.b abab %}").options.a.b;
test.equal("abab",a);
}
View
4 tests/tests/test-37.js
@@ -1,6 +1,6 @@
this.name = "$scope test";
-this.run = function(test, nTPL, callback) {
- var a = nTPL("{%= $scope.test = ($scope.test || 0) +1 %}");
+this.run = function(test, ntpl, callback) {
+ var a = ntpl("{%= $scope.test = ($scope.test || 0) +1 %}");
var a1 = a();
var a2 = a();
test.equal(a1 + a2, "12");
View
4 tests/tests/test-4.js
@@ -1,6 +1,6 @@
this.name = "Simple readfile (args is object)";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "./tests/file-1"
})();
test.equal("test", a);
View
4 tests/tests/test-5.js
@@ -1,5 +1,5 @@
this.name = "1 Plain & 1 Code";
-this.run = function(test, nTPL) {
- var a = nTPL("test-{%= 'test' %}")();
+this.run = function(test, ntpl) {
+ var a = ntpl("test-{%= 'test' %}")();
test.equal("test-test", a);
}
View
4 tests/tests/test-6.js
@@ -1,5 +1,5 @@
this.name = "4 Plain & 4 Code";
-this.run = function(test, nTPL) {
- var a = nTPL("12-{%= '34' %}-56-{%= '78' %}-90-{%= '12' %}-34-{%= '56' %}")();
+this.run = function(test, ntpl) {
+ var a = ntpl("12-{%= '34' %}-56-{%= '78' %}-90-{%= '12' %}-34-{%= '56' %}")();
test.equal("12-34-56-78-90-12-34-56", a);
}
View
4 tests/tests/test-7.js
@@ -1,6 +1,6 @@
this.name = "Arguments without using";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "test",
args: ["a"]
})();
View
4 tests/tests/test-8.js
@@ -1,6 +1,6 @@
this.name = "Arguments and using it";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "test-{%= a %}",
args: ["a"]
})({
View
4 tests/tests/test-9.js
@@ -1,6 +1,6 @@
this.name = "Many Arguments and using it";
-this.run = function(test, nTPL) {
- var a = nTPL({
+this.run = function(test, ntpl) {
+ var a = ntpl({
template: "1-{%= a1 %}-2-{%= a2 %}-3-{%= a3 %}-4-{%= a4 %}",
args: ["a1","a2","a3","a4"]
})({
View
2  tpl/index.html
@@ -3,7 +3,7 @@
{%extends 'base' %}
-{%block 'title' %}nTPL Simple demo{%/block %}
+{%block 'title' %}ntpl Simple demo{%/block %}
{%block 'head' %}
{%
View
18 wscript
@@ -14,14 +14,14 @@ def configure(conf):
conf.check_tool('node_addon')
def build(bld):
- nTPL = bld.new_task_gen('cxx', 'shlib', 'node_addon')
- nTPL.cxxflags = ["-g",]
- nTPL.target = 'nTPL.native'
- nTPL.source = bld.path.ant_glob('nTPL.native/*.cc')
- nTPL.includes = 'nTPL.native/'
+ ntpl = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ ntpl.cxxflags = ["-g",]
+ ntpl.target = 'ntpl.native'
+ ntpl.source = bld.path.ant_glob('ntpl.native/*.cc')
+ ntpl.includes = 'ntpl.native/'
def shutdown():
- if exists('./lib/nTPL/nTPL.native.node'):
- unlink('./lib/nTPL/nTPL.native.node');
- if exists('./build/default/nTPL.native.node'):
- copy('./build/default/nTPL.native.node', './lib/nTPL/nTPL.native.node')
+ if exists('./lib/ntpl/ntpl.native.node'):
+ unlink('./lib/ntpl/ntpl.native.node');
+ if exists('./build/default/ntpl.native.node'):
+ copy('./build/default/ntpl.native.node', './lib/ntpl/ntpl.native.node')
Please sign in to comment.
Something went wrong with that request. Please try again.