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.2 to 0.1.3

25

lib/handlebar-rider.js
// handlebar rider
handlebars = require('handlebars');

@@ -96,6 +98,8 @@ uglify = require('uglify-js');

var output = ['(function() {\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; Handlebars.partials = Handlebars.templates; \n'];
output = ['(function() {'];
output.push('\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\n');
output.push('\n Handlebars.partials = Handlebars.templates;\n')
for(var t = 0; t < rider.templates.length; t++){
var data = fs.readFileSync(rider.templates[t].file, 'utf8');
data = fs.readFileSync(rider.templates[t].file, 'utf8');

@@ -106,3 +110,18 @@ // clean the data a bit

var compiled = 'templates[\'' + rider.templates[t].namespace + '\'] = template(' + handlebars.precompile(data, {}) + ');\n'
// check for partial conventions
if (rider.templates[t].namespace.indexOf('/_') > 0){
compiled = 'templates[\'' + rider.templates[t].namespace.replace(/\/_/,'_') + '\'] = template(' + handlebars.precompile(data, {}) + ');\n'
} else if( rider.templates[t].namespace.indexOf('partial') != 0 ) {
compiled = 'templates[\'' + rider.templates[t].namespace + '\'] = template(' + handlebars.precompile(data, {}) + ');\n'
} else {
compiled = 'templates[\'' + rider.templates[t].namespace.replace(/partials\//,'') + '\'] = template(' + handlebars.precompile(data, {}) + ');\n'
}
output.push(compiled);

@@ -109,0 +128,0 @@

2

package.json

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

"description" : "Watches a directory and precompiles handlebars templates",
"version" : "0.1.2",
"version" : "0.1.3",

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

@@ -1,17 +0,15 @@

handlebar-rider
# handlebar-rider
================
Command line tool that will watch a handlebars template directory pre-compile containing handlebars template files and concatenate them
into a single javascript file in build/public. The directory structure you use will namespace the templates as expected with JST et all
into a single javascript file in build/public.
Run-time usage example:
The directory structure you use will namespace the templates with ['directory/template'] as with JST et all
html_output = Handlebars.templates['users/view'](data)
Install:
## Install:
npm install -g handlebar-rider
Usage:
## Usage:

@@ -26,1 +24,41 @@ handlebar-rider path/to/your/handlebars/dir/

## Run-time usage example:
html_output = Handlebars.templates['users/view'](data)
## Partial Support/Conventions:
There are two methods for using partials within your templates:
1. Global partials
If you create a partials in a directory, aptly called "partials" which lives within your handlebars templates directory, the
handlebars files will be pre compile and available in your templates
2. Scoped partials
If you prefix your template file name with an underscore, you can can access it as directory_partial
### Example directory structure:
templates
-- users
- _list.hb
- _form.hb
- edit.hb
- view.hb
-- partials
- photo_uploader.hb
### And usage:
<h1>Edit User</h1>
{{> users_list}}
{{> users_form}}
{{> photo_uploader}}
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