GithubHelp home page GithubHelp logo

mincer-ember-hbs-engine's Introduction

A Mincer engine to for serving Ember-friendly Handlebars templates.

Mincer is a badass JavaScript port of Sprockets that makes it super-duper easy to serve dynamically generated assets in your connect or express app. You'll want to be familiar with its use before you try using this package.

Note*: this engine overrides the built-in Handlebars engine. Furthermore, there is no need to pair your template files with the built-in JST engine. Naming your files [my-template].hbs will do.

How to use this old thing

First, install the package:

npm install mincer-ember-hbs-engine --save

Then, wherever you've set up your Mincer environment:

// Requirements
var mincer = require('mincer');
var mincerEmberHbs = require('mincer-ember-hbs-engine');

// Asset pipeline
var pipeline = new mincer.Environment();
pipeline.registerEngine('.hbs', mincerEmberHbs);

Assuming a directory structure similar to this…

app/
    assets/
        javascripts/
            templates/
                application.hbs
                home.hbs
            templates.js

…you can now create a manifest for your templates, like this:

app/assets/javascripts/templates.js

//= require_tree ./templates

But wait a second…

This engine never defines a default Ember.TEMPLATES object like the JST engine does!

Not to fear, Ember handles defining Ember.TEMPLATES as an empty object. Make sure that your templates aren't instantiated before Ember and you'll be A-OK.

What if I want to use JST templates at the same time?

At this time, the only way to achieve that would be to register this engine under a different file extension, leaving the default .hbs engine intact.

Credits

Uproarious applause goes to @ixti and @puzrin for their incredible work on Mincer. Further thanks for @Nthalk for a great example of a simple Mincer engine.

Author

Mike Fowler (@michaelrfowler on Twitter)

License

Copyright (c) 2014 Mike Fowler

Released under the MIT license. See LICENSE for details.

mincer-ember-hbs-engine's People

Contributors

mikefowler avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.