Comparing version 1.0.5 to 1.0.6
@@ -42,3 +42,3 @@ var jqtpl = require('./jqtpl'); | ||
var name = options.filename || markup; | ||
// express calls compile if the template have to be recompiled | ||
@@ -51,11 +51,9 @@ // so we have to clean cache before compile | ||
if (options.debug) { | ||
// print the template generator fn | ||
exports.debug(jqtpl.template[name]); | ||
} | ||
return function render(locals) { | ||
var tpl = jqtpl.tmpl(name, locals, options); | ||
if (options.debug) { | ||
// print the template generator fn | ||
exports.debug(jqtpl.template[name]); | ||
} | ||
return tpl; | ||
return jqtpl.tmpl(name, locals, options); | ||
}; | ||
@@ -62,0 +60,0 @@ }; |
{ | ||
"name": "jqtpl", | ||
"description": "A port of jQuery's template engine", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"author": "Oleg Slobodskoi <oleg008@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -220,3 +220,3 @@ ## This is a port of jQuery's Template Engine to nodejs | ||
// myaction.html | ||
<div>{{partial({test) "mypartial"}}</div> | ||
<div>{{partial(test) "mypartial"}}</div> | ||
@@ -223,0 +223,0 @@ // mypartial.html |
@@ -28,8 +28,8 @@ var o = { | ||
app.set('view engine', 'html'); | ||
app.set('views', o.root + '/views'); | ||
app.set('views', o.root + '/1'); | ||
app.set('view options', {layout: false}); | ||
// qunit copies jqtpl.express exports to global | ||
app.register('.html', global); | ||
app.get('/:view', function(req, res){ | ||
res.render(req.params.view, locals); | ||
app.get('/*', function(req, res){ | ||
res.render(req.url.substr(1), locals); | ||
}); | ||
@@ -113,2 +113,17 @@ app.listen(o.port); | ||
test("rendering template with a layout turned on", function() { | ||
this.app.set('view options', {layout: true}); | ||
this.app.set('views', o.root + '/2'); | ||
locals = { | ||
mylocal: "mylocal" | ||
}; | ||
stop(); | ||
request('/views/test', function(data) { | ||
equal(data, 'abc mylocal', 'template and layout rendered correctly'); | ||
start(); | ||
}); | ||
}); | ||
test("rendering multiple times of the same template #29", function() { | ||
@@ -139,1 +154,4 @@ var template = 'Just example ${example}' | ||
}); | ||
24394
15
516