express-partials
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -0,1 +1,8 @@ | ||
0.0.6 / 2012-09-10 | ||
================== | ||
* Added tests and fixes for layout path resolution. (thanks to Jakub Nešetřil @zzen) | ||
* Added Travis-CI. | ||
0.0.5 / 2012-06-29 | ||
@@ -2,0 +9,0 @@ ================== |
@@ -5,2 +5,3 @@ var path = require('path') | ||
, resolve = path.resolve | ||
, dirname = path.dirname | ||
, extname = path.extname | ||
@@ -64,3 +65,7 @@ , basename = path.basename; | ||
var ext = extname(name) || '.'+(res.app.get('view engine') || 'ejs'); | ||
_render(basename(layout,ext)+ext, options, fn); | ||
var root = req.app.get('views') || process.cwd() + '/views'; | ||
var dir = dirname(name) == '.' ? root : resolve(root,dirname(name)); | ||
layout = dirname(lookup(dir, layout, ext))+(path.sep||'/')+basename(layout,ext)+ext; | ||
_render(layout, options, fn); | ||
}) | ||
@@ -67,0 +72,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Express 3.x Layout & Partial support.", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "https://github.com/publicclass/express-partials" |
@@ -0,1 +1,2 @@ | ||
[![build status](https://secure.travis-ci.org/publicclass/express-partials.png)](http://travis-ci.org/publicclass/express-partials) | ||
# express-partials | ||
@@ -2,0 +3,0 @@ |
@@ -45,2 +45,11 @@ var express = require('express') | ||
app.get('/subdir',function(req,res,next){ | ||
res.render('subdir/index.ejs') | ||
}) | ||
app.get('/subdir-explicit',function(req,res,next){ | ||
res.render('subdir/index.ejs', {layout: 'subdir/layout.ejs', list:[{name:'one'},{name:'two'}]}) | ||
}) | ||
/* Use `register` to substitute the file extension. */ | ||
@@ -249,3 +258,27 @@ app.engine('.j',require('jade').__express); | ||
}) | ||
describe('GET /subdir',function() { | ||
it('should render index.ejs with layout.ejs (both inside subdir)', function(done) { | ||
request(app) | ||
.get('/subdir') | ||
.end(function(res) { | ||
res.should.have.status(200); | ||
res.body.should.equal('<html><title>subdir layout</title><body><h2>Hello World</h2></body></html>'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
describe('GET /subdir-explicit',function() { | ||
it('should render index.ejs with layout.ejs (both inside subdir) when layout is specified in locals', function(done) { | ||
request(app) | ||
.get('/subdir-explicit') | ||
.end(function(res) { | ||
res.should.have.status(200); | ||
res.body.should.equal('<html><title>subdir layout</title><body><h2>Hello World</h2></body></html>'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23648
23
616
99