-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from lavaxun/master
fix cachePartials extension name
- Loading branch information
Showing
8 changed files
with
46 additions
and
1 deletion.
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
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,35 @@ | ||
'use strict'; | ||
var assert = require('assert'); | ||
var hbs = require('..'); | ||
var path = require('path'); | ||
var H = require('./helpers'); | ||
|
||
|
||
// MEANJS is using custom extension .server.view.html instead of .hbs | ||
// https://github.com/meanjs/mean | ||
describe('custom extension for partials view', function() { | ||
var dirname = path.join(__dirname, 'views/customExtension'); | ||
var render = hbs.create().express4({ | ||
extname: '.server.view.html', | ||
partialsDir: dirname + '/partialsDir' | ||
}); | ||
|
||
it('should allow rendering multiple partials with custom extension', function(done) { | ||
function check(err, html) { | ||
assert.ifError(err); | ||
assert.equal( | ||
'<html>' + | ||
'<subpartial>1</subpartial>' + | ||
'<partial>1</partial>' + | ||
'<subpartial>2</subpartial>' + | ||
'<partial>2</partial>' + | ||
'</html>', | ||
H.stripWs(html)); | ||
done(); | ||
} | ||
|
||
var options = {cache: true, settings: {views: dirname }}; | ||
render(dirname + '/template.server.view.html', options, check); | ||
}); | ||
|
||
}); |
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 @@ | ||
<html>{{{body}}}</html> |
1 change: 1 addition & 0 deletions
1
test/views/customExtension/partialsDir/partial1.server.view.html
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 @@ | ||
<partial>1</partial> |
1 change: 1 addition & 0 deletions
1
test/views/customExtension/partialsDir/partial2.server.view.html
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 @@ | ||
<partial>2</partial> |
1 change: 1 addition & 0 deletions
1
test/views/customExtension/partialsDir/subs/subPartial1.server.view.html
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 @@ | ||
<subpartial>1</subpartial> |
1 change: 1 addition & 0 deletions
1
test/views/customExtension/partialsDir/subs/subPartial2.server.view.html
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 @@ | ||
<subpartial>2</subpartial> |
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,5 @@ | ||
{{!< layout}} | ||
{{> subs/subPartial1}} | ||
{{> partial1}} | ||
{{> subs/subPartial2}} | ||
{{> partial2}} |