npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-htmlbars

v0.4.0

Published

To compile htmlbars templates for Ember App or handlebars templates

Downloads

12

Readme

gulp-htmlbars

NPM

Build Status NPM version NPM download Dependency Status

Code Climate Test Coverage

Warning

This repo is going to be deprecated and merged its features into gulp-handlebars. At the same time, I would be joining as a maintainer of gulp-handlebars repository along with lzad. Migration should be done by the end of March, 2015.

To compile htmlbars and handlebars templates for gulp

Usage

Install gulp-htmlbars as a development dependency:

npm install --save-dev gulp-htmlbars

Compiling handlebars templates for the browser. (AMD format)

gulp-wrap-amd, is maintained by @phated and myself, can be used to safely convert templates into AMD syntax available for use in the browser.

First, install development dependencies:

npm install --save-dev gulp-htmlbars gulp-wrap-amd gulp-concat gulp

Given the following directory structure:

├── gulpfile.js              # Your gulpfile
└── source/                  # Your application's source files
    └── templates/           # A folder containing templates named with dot notation
        └── header.hbs       # A template that will be available as MyApp.templates.home.header

To compile all templates in source/templates/ to build/js/templates.js under the MyApp.templates namespace:

gulpfile.js

Compiling htmlbars templates for the browser. (AMD format)

gulpfile.js

gulp.task('templates', function(){
  gulp.src('source/templates/*.hbs')
    .pipe(htmlbars({
      templateCompiler: require('../bower_components/ember/ember-template-compiler')
    }))
    .pipe(wrap({
      deps:         ['exports'],          // optional, dependency array
      params:       ['__exports__'],      // optional, params for callback
      moduleRoot:   'source/templates/',  // optional
      modulePrefix: 'rocks/'              // optional
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('build/js/'));
});

Compiling templates for use in Ember applications

See the ember-rocks for a full example of compiling templates for Ember.

You can use gulp-replace to modfiy the output, and then use within Ember, Ember-Rocks, or Ember-Cli:

gulpfile.js

gulp.task('templates', function(){
  gulp.src('source/templates/*.hbs')
      .pipe(htmlbars({
        templateCompiler: require('../bower_components/ember/ember-template-compiler')
      }))
    .pipe(wrap({
      deps:         ['exports'],          // dependency array
      params:       ['__exports__'],        // params for callback
      moduleRoot:   'source/templates/',
      modulePrefix: 'rocks/'
    }))
    .pipe(replace(
      /return export default/, 'return __exports__["default"] ='
    ))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('build/js/'));
});

Test

Before running the tests, need to run bower install at the root level, to have an Ember package in the local directory ("./bower_components"). HTMLBars is in a heavy development along with Ember project, each Ember release (Beta or Stable) will ship its bundled compiler for specific Ember version.

Once you have the Ember-template-compiler dependency ready, you could run

npm test  # kick start your local tests

API

htmlbars(options)

options.templateCompiler [required]

Type: Function Default: null

The file path of ember-template-compiler script which bundled with each version of Ember.js. Each Ember core version (beta or stable) will bundle the ember-template-compiler.js script to compile HTMLBars template.

Ex: templateCompiler: require('../bower_components/ember/ember-template-compiler')

LICENSE

Copyright (c) 2015 Matt Ma

gulp-htmlbars is MIT Licensed.