From 7538b8556c6e7875dcb5fe7cfff945d7a4da0bd0 Mon Sep 17 00:00:00 2001 From: Blessan Mathew Date: Tue, 4 Jun 2013 23:06:40 +0530 Subject: [PATCH] Added BOM removal flag. Byte order mark is now removed from the beginning of the files when b flag is used. --- bin/handlebars | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/handlebars b/bin/handlebars index 4835770f9..b30a1fe19 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -70,6 +70,11 @@ var optimist = require('optimist') 'description': 'Template extension.', 'alias': 'extension', 'default': 'handlebars' + }, + 'b': { + 'type': 'boolean', + 'description': 'Removes the BOM (Byte Order Mark) from the beginning of the templates.', + 'alias': 'bom' } }) @@ -147,6 +152,10 @@ function processTemplate(template, root) { }); } else { var data = fs.readFileSync(path, 'utf8'); + + if (argv.bom && data.indexOf('\uFEFF') === 0) { + data = data.substring(1); + } var options = { knownHelpers: known,