Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

handlebar-rider

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handlebar-rider - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

73

lib/handlebar-rider.js

@@ -23,4 +23,4 @@

templates_dir: './app/handlebars/',
outfile: './public/javascript/templates.js',
in: './app/handlebars/',
out: './public/javascript/templates.js',
templates: [],

@@ -80,3 +80,3 @@ minify: true

console.log(color.green + '[handlebar-rider] Change detected to file, recompiling' + color.reset);
console.log(color.green + '[handlebar-rider] change detected to file, recompiling' + color.reset);
compileTemplates();

@@ -90,4 +90,4 @@

console.log(color.blue + '[handlebar-rider] New or removed file detected, recompiling' + color.reset);
readAndCompile(rider.templates_dir);
console.log(color.blue + '[handlebar-rider] new or removed file detected, recompiling' + color.reset);
readAndCompile(rider.in);

@@ -103,2 +103,4 @@ };

output.push('\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\n');
// todo - figure out cleaner way to register partials as actual partials
output.push('\n Handlebars.partials = Handlebars.templates;\n')

@@ -118,3 +120,2 @@ for(var t = 0; t < rider.templates.length; t++){

} else if( rider.templates[t].namespace.indexOf('partial') != 0 ) {

@@ -124,3 +125,2 @@

} else {

@@ -157,7 +157,7 @@

fs.writeFileSync(rider.outfile, output, 'utf8');
fs.writeFileSync(rider.out, output, 'utf8');
} catch(e){
console.log(color.red + '[handlebar-rider] ERROR! Destination file or directory does not exist.' + color.reset + '\n:' + e);
console.log(color.red + '[handlebar-rider] ERROR! destination file or directory does not exist.' + color.reset + '\n:' + e);

@@ -169,3 +169,3 @@ }

var readAndCompile = function(dir, argv){
var readAndCompile = function(dir, watch){

@@ -178,3 +178,3 @@ //read files in the directory

if(err)
throw new Error('Directory does not exists: ' + dir)
throw new Error('directory does not exists: ' + dir)

@@ -190,6 +190,6 @@ rider.templates = []

// watch the file
fs.watch(info[1], fileHasChanged)
if(watch) fs.watch(info[1], fileHasChanged)
// get the template namespace by using the extra directory
template_dir = rider.templates_dir.toString();
template_dir = rider.in.toString();
file_and_dir = info[1].substr( (info[1].indexOf(template_dir) + template_dir.length) + 1, info[1].length);

@@ -208,3 +208,3 @@ namespaced = file_and_dir.replace(/\.hb/,'');

// watch the directory for new / removed files
fs.watch(info[1], directoryHasChanged)
if(watch) fs.watch(info[1], directoryHasChanged)

@@ -219,5 +219,5 @@ }

console.log(color.red + '[handlebar-rider] ERROR! Check to be sure your directories exist. ' + color.reset + "\n" + e + "\n");
console.log('[handlebar-rider] Input directory: ' + dir);
console.log('[handlebar-rider] Destination file: ' + rider.outfile + "\n");
console.log(color.red + '[handlebar-rider] ERROR! check to be sure your directories exist. ' + color.reset + "\n" + e + "\n");
console.log('[handlebar-rider] input directory: ' + dir);
console.log('[handlebar-rider] destination file: ' + rider.out + "\n");
if(rider.help)

@@ -236,4 +236,2 @@ console.log(rider.help)

//get options specified on command line
argv = optimist

@@ -244,6 +242,9 @@ .usage('Compile a directory of handlebars templates into a single javascript file.\nCommand Line Usage: ')

.describe('i','Specify an input templates directory')
.default('i', rider.templates_dir)
.default('i', rider.in)
.alias('o','out')
.describe('o','Specify an output file into which templates are compiled')
.default('o', rider.outfile)
.default('o', rider.out)
.alias('w','watch')
.describe('w','Watch your handlebars files and compile when changes occur')
.default('w', false)
.alias('r','readable')

@@ -255,18 +256,34 @@ .describe('r','Make the output more readable by avoiding default minification')

dir = argv.in;
rider.templates_dir = dir;
rider.in = dir;
rider.minify = !argv.readable;
rider.outfile = argv.out;
rider.out = argv.out;
rider.watch = argv.watch;
rider.help = optimist.help()
//compile on startup
console.log(color.green + '[handlebar-rider] Compiling template directory ' + dir + ' to ' + rider.outfile + color.reset);
console.log(color.yellow + '[handlebar-rider] Watching template directory ' + dir + color.reset);
console.log(color.green + '[handlebar-rider] compiling template directory ' + dir + ' to ' + rider.out + color.reset);
if(rider.watch)
console.log(color.yellow + '[handlebar-rider] watching template directory ' + dir + color.reset);
readAndCompile(dir, argv);
readAndCompile(dir, rider.watch);
}
// export this function for module use
exports.readAndCompile = readAndCompile
// export functions for module use
exports.configure = function(config){ rider = config; }
exports.watch = function(){
console.log(color.yellow + '[handlebar-rider] watching template directory ' + rider.in + color.reset);
readAndCompile(rider.in, true);
}
exports.compile = function(){
console.log(color.green + '[handlebar-rider] compiling template directory ' + dir + ' to ' + rider.out + color.reset);
readAndCompile(rider.in, false);
}

@@ -273,0 +290,0 @@ })()

@@ -5,3 +5,3 @@ {

"description" : "Watches a directory and precompiles handlebars templates",
"version" : "0.1.6",
"version" : "0.1.7",

@@ -8,0 +8,0 @@ "repository" : {

@@ -21,4 +21,7 @@ # handlebar-rider

-o, --out Specify an output file into which templates are compiled [default: "./public/javascript/templates.js"]
-w, --watch Watch your handlebars files and compile when changes occur [default: false]
-r, --readable Make the output more readable by avoiding default minification [default: false]
## npm module usage

@@ -28,7 +31,8 @@

hrb.configure({
templates_dir: '/path/to/your/templates/'
outfile: '/path/to/output.js',
in: '/path/to/your/templates/'
out: '/path/to/output.js',
minify: false
})
hbr.run()
hbr.compile()
hbr.watch()

@@ -35,0 +39,0 @@ ## Run-time usage example:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc