Giter VIP home page Giter VIP logo

emblem.js's Introduction

Emblem: Handlebars + Indentation + Ember-compatibility

Emblem.js is an indentation-based templating language that compiles to Handlebars. It is therefore

  1. Efficiently/easily precompilable
  2. Compilable in the browser
  3. Fully compatible with Ember.js's auto-updating templates
  4. Way more fun to write/maintain than {{mustached}}'d HTML

Check out the Emblem.js docs site http://www.emblemjs.com.

Syntax Examples

Emblem.js Syntax

Using Emblem in your application

You can use Emblem to compile either to vanilla Handlebars or Emberized Handlebars. Let's assume you're compiling to Emberized Handlebars for use with an Ember app.

Compiling in the Browser

Follow the pattern in this JSBin:

  1. Include Handlebars
  2. Include Emblem
  3. Include Ember

If you have a recent enough version of Ember, all the Emblem code you put into <script type="text/x-emblem"> tags will get compiled and stripped out of the DOM. If you're using an out-of-date Ember, you can trigger this to happen manually before app initialization via

Ember.onLoad('application', Emblem.compileScriptTags);

Via Rails 3.1+

Add the following to your Gemfile:

gem 'emblem-rails'

emblem-rails presently depends on ember-rails. With these two gems, any templates ending in .emblem will be (pre)compiled with Emblem.js.

Also, check out the demo app which uses the above configuration.

Via Rake Pipeline

Coming extremely soon.

All Emblem Plugins

  1. emblem-rails
  2. barber-emblem, a Precompilation library for Ruby (used in ember-rails)
  3. emblem-brunch, Emblem support for Brunch.io

Building Emblem.js

Clone the repo, then run:

bundle
rake

This will also automatically run the test suite.

Syntax Highlighting

For now, please refer to syntax highlighting solutions for Slim, which is not much different from Ember's. At some point, we'll have something even more custom tailored to Emblem (feel free to take a swing at it and send in a PR).

Vim users with Slim syntax highlighting can set this in their .vimrcs:

au BufNewFile,BufRead *.emblem set filetype=slim

TODO / Contribute

  • Syntax suggestions / improvements
  • Syntax highlighting
  • Rake pipeline
  • Plugins for all sorts of frameworks
  • Refactor the code to be cross-platform (browser/Node/etc). It currently is now, it's just mad ugly.

Pull Requests absolutely welcome and encouraged, just don't send me non-trivial changes without the test cases to back them up.

emblem.js's People

Contributors

machty avatar

Watchers

James Cloos avatar Scott Sheffield 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.