This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support partial block statements with --traverse
- Loading branch information
Showing
5 changed files
with
34 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,5 @@ | ||
var Handlebars = require("hbsfy/runtime"); | ||
|
||
var template = require("./block_partial_require.hbs"); | ||
|
||
document.body.innerHTML = template(); |
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 @@ | ||
{{#> ./block_partial_required.hbs}}<p>inside</p>{{/./block_partial_required.hbs}} |
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,26 @@ | ||
var concat = require("concat-stream"); | ||
var browserify = require("browserify"); | ||
var assert = require("assert"); | ||
var vm = require("vm"); | ||
|
||
var b = browserify(__dirname + "/blockPartialBrowserCode.js"); | ||
b.transform(require("hbsfy"), { traverse: true }); | ||
|
||
var context = { | ||
document: { | ||
body: {} | ||
} | ||
}; | ||
|
||
b.bundle().pipe(concat(function(data) { | ||
var bundle = data.toString(); | ||
assert(/require\('.\/block_partial_required\.hbs'\)/.test(bundle), 'looking for require'); | ||
assert(/block_partial_required.hbs['"]\:/.test(bundle), 'looking for included partial'); | ||
assert(/var partial\$0/.test(bundle), 'looking for partial temp var'); | ||
assert(/, partial\$0/.test(bundle), 'looking for partial registration'); | ||
vm.runInNewContext(bundle, context); | ||
})); | ||
|
||
setTimeout(function() { | ||
assert.equal(context.document.body.innerHTML.trim(), "<div><p>inside</p></div>"); | ||
}, 400); |
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 @@ | ||
<div>{{> @partial-block}}</div> |