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.
We'll now use the handlebars module directly. Thanks to @kamicane esamattis/node-handlebars-runtime#3
- Loading branch information
Showing
9 changed files
with
87 additions
and
16 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
language: node_js | ||
before_script: | ||
# Tests require that hbsfy is requireable by its name. We cannot use relative | ||
# require calls because 'require("hbsfy/runtime");' will be compiled in to | ||
# the browserify bundles. | ||
- sudo npm link | ||
node_js: | ||
- "0.8" | ||
- "0.10" |
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,11 @@ | ||
var hbsBase = require("handlebars/lib/handlebars/base"); | ||
var hbsUtils = require("handlebars/lib/handlebars/utils"); | ||
var hbsRuntime = require("handlebars/lib/handlebars/runtime"); | ||
|
||
var Handlebars = hbsBase.create(); | ||
hbsUtils.attach(Handlebars); | ||
hbsRuntime.attach(Handlebars); | ||
|
||
module.exports = Handlebars; | ||
|
||
// module.exports = require("handlebars"); |
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,9 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
cd test/ | ||
npm link hbsfy | ||
node test.js | ||
node browserify_test.js | ||
|
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,12 @@ | ||
|
||
var Handlebars = require("hbsfy/runtime"); | ||
|
||
Handlebars.registerHelper("upcase", function(s) { | ||
return s.toUpperCase(); | ||
}); | ||
|
||
var template = require("./hello.hbs"); | ||
|
||
document.body.innerHTML = template({ | ||
msg: "hello" | ||
}); |
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 + "/browsercode.js"); | ||
b.transform(require("hbsfy")); | ||
|
||
// Browser mock | ||
var context = { | ||
document: { | ||
body: {} | ||
} | ||
}; | ||
|
||
b.bundle().pipe(concat(function(data) { | ||
console.log("Bundle size", data.length); | ||
assert(data.length < 15000, "Bundle is too big! Maybe full Handlebars got compiled in?"); | ||
vm.runInNewContext(data.toString(), context); | ||
})); | ||
|
||
setTimeout(function() { | ||
assert.equal(context.document.body.innerHTML.trim(), "<h1>HELLO</h1>"); | ||
}, 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