Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mario L Gutierrez
committed
Jan 17, 2014
1 parent
0ecca1c
commit 2a9fcfd
Showing
9 changed files
with
133 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
; indicate this is the root of the project | ||
|
||
[*] | ||
indent_style = space | ||
end_of_line = lf | ||
|
||
[*.js] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
module.exports = function configureGrunt(grunt) { | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
|
||
mochacli: { | ||
options: { | ||
ui: 'bdd', | ||
reporter: 'spec' | ||
}, | ||
mochacli: { | ||
options: { | ||
ui: 'bdd', | ||
reporter: 'spec' | ||
}, | ||
|
||
all: { | ||
src: ['test/*.js'] | ||
} | ||
} | ||
}); | ||
all: { | ||
src: ['test/*.js'] | ||
} | ||
} | ||
}); | ||
|
||
grunt.registerTask('setProductionEnv', function () { | ||
// Use 'production' config | ||
process.env.NODE_ENV = 'production'; | ||
}); | ||
grunt.registerTask('setProductionEnv', function () { | ||
// Use 'production' config | ||
process.env.NODE_ENV = 'production'; | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-mocha-cli'); | ||
grunt.loadNpmTasks('grunt-mocha-cli'); | ||
|
||
// Run tests | ||
grunt.registerTask('default', ['mochacli:all', 'setProductionEnv', 'mochacli:all']); | ||
}; | ||
// Run tests | ||
grunt.registerTask('default', ['mochacli:all', 'setProductionEnv', 'mochacli:all']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
var request = require('supertest'); | ||
var assert = require('assert'); | ||
var hbs = require('..'); | ||
|
||
|
||
function stripWs(s) { | ||
return s.replace(/\s+/g, ''); | ||
} | ||
|
||
function createLocals(which, viewsDir, locals) { | ||
if (!locals) locals = {}; | ||
var opts = {}; | ||
if (which === 'express3') { | ||
opts.settings = { | ||
views: viewsDir, | ||
}; | ||
opts.cache = process.env.NODE_ENV === 'production'; | ||
opts.settings.views = viewsDir; | ||
for (var k in locals) { | ||
if (!locals.hasOwnProperty(k)) continue; | ||
opts[k] = locals[k]; | ||
} | ||
} | ||
return opts; | ||
} | ||
|
||
describe('layouts', function() { | ||
var app; | ||
|
||
beforeEach(function() { | ||
var example = require('../example/app'); | ||
app = example.create(hbs.create()); | ||
}); | ||
|
||
|
||
describe('layoutsDir', function() { | ||
var app; | ||
|
||
beforeEach(function() { | ||
app = require('../example/app-layoutsDir'); | ||
}); | ||
|
||
it('should render layout declared in markup', function(done) { | ||
request(app) | ||
.get('/fruits') | ||
.expect(/DECLARATIVE LAYOUT/, done); | ||
}); | ||
|
||
it('should allow specifying layout in locals without dir', function(done) { | ||
request(app) | ||
.get('/veggies') | ||
.expect(/PROGRAMMATIC LAYOUT/, done); | ||
}); | ||
|
||
it('should still allow specifying layout in locals with dir', function(done) { | ||
request(app) | ||
.get('/veggies/explicit-dir') | ||
.expect(/PROGRAMMATIC LAYOUT/, done); | ||
}); | ||
}); | ||
|
||
describe('disableLayoutDirective', function() { | ||
var dirname = __dirname + '/views/disableLayoutDirective'; | ||
|
||
it ('should process directive without option', function(done) { | ||
var render = hbs.create().express3({ | ||
}); | ||
var locals = createLocals('express3', dirname); | ||
|
||
render(dirname + '/index.hbs', locals, function(err, html) { | ||
assert.equal('<dld>dld</dld>', stripWs(html)); | ||
done(); | ||
}); | ||
}); | ||
|
||
it ('should not process directive with option set', function(done) { | ||
var render = hbs.create().express3({ | ||
disableLayoutDirective: true | ||
}); | ||
var locals = createLocals('express3', dirname); | ||
render(dirname + '/index.hbs', locals, function(err, html) { | ||
assert.equal('dld', stripWs(html)); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{!< layouts/default}} | ||
dld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<dld>{{{body}}}</dld> |