Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for handlebars templates #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helpers/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var TerraformError = exports.TerraformError = require("../error").TerraformError
*/

var processors = exports.processors = {
"html": ["jade", "ejs", "md"],
"html": ["jade", "ejs", "md", "hbs"],
"css" : ["styl", "less", "scss"],
"js" : ["coffee"]
}
Expand Down
28 changes: 28 additions & 0 deletions lib/template/processors/hbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var Handlebars = require('handlebars')
var TerraformError = require("../../error").TerraformError

module.exports = function(fileContents, options){

return {
compile: function(){
return Handlebars.compile(fileContents.toString(), options)
},

parseError: function(error){

var arr = error.message.split("\n")
var path_arr = arr[0].split(":")

error.lineno = parseInt(error.lineno || path_arr[path_arr.length -1] || -1)
error.message = arr[arr.length - 1]
error.name = error.name
error.source = "Handlebars"
error.dest = "HTML"
error.filename = error.path || options.filename
error.stack = fileContents.toString()

return new TerraformError(error)
}
}

}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"node-sass": "0.7.0",
"marked": "0.2.9",
"less" : "1.5.1",
"stylus": "0.40.0"
"stylus": "0.40.0",
"handlebars": "1.3.0"
},
"devDependencies": {
"mocha": "1.8.2",
Expand Down