GithubHelp home page GithubHelp logo

emblem-brunch's Introduction

emblem-brunch

Adds Emblem support to brunch.

Installation

Add "emblem-brunch": "x.y.z" to package.json of your brunch app.

Pick a plugin version that corresponds to your minor (y) brunch version.

If you want to use git version of plugin, add "emblem-brunch": "git+https://github.com/machty/emblem-brunch.git".

Download Emblem and Handlebars.

Usage

exports.config =
  files:
    # ...
    templates:
      precompile: true
      root: 'templates'
      defaultExtension: 'emblem'
      joinTo: 'javascripts/app.js'
      paths:
        # If you don't specify jquery and ember there,
        # raw (non-Emberized) Handlebars templates will be compiled.
        jquery: 'vendor/scripts/jquery-1.9.0.min.js'
        ember: 'vendor/scripts/ember-latest.js'
        handlebars: 'handlebars.js'
        emblem: 'emblem.js'

With Ember

Require templates in your main script.

require 'templates/application'
require 'templates/index'

This will configure Ember.TEMPLATES automatically.

Without Ember

Require templates where you need them.

index_template = require 'templates/index'

Credits

Based on handlebars-brunch and ember-precompiler-brunch.

emblem-brunch's People

Contributors

140am avatar andriijas avatar cesutherland avatar machty avatar paulmillr avatar valpackett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

emblem-brunch's Issues

Error on compile in Emblem-Brunch

I'm trying to get emblem-brunch to work but getting a weird error:

TypeError: Object object has no method 'run'
at EmblemCompiler.module.exports.EmblemCompiler.setup (E:\node_modules\emblem-brunch\lib\index.js:27:21)
at new EmblemCompiler (E:\node_modul
es\emblem-brunch\lib\index.js:43:14)

If I use the example I get error on watch that the emblem files aren't compiling because files.templates.paths isn't defined.

Which I've set up as follows resulting in the first error: (using brunch-with-hampsters)
templates:
precompile: true
root: 'app/templates'
joinTo: 'javascripts/app.js' : /^app/
defaultExtension: 'emblem'
paths:
# If you don't specify jquery and ember there,
# raw (non-Emberized) Handlebars templates will be compiled.
jquery: 'vendor/scripts/jquery-1.9.0.min.js'
ember: 'vendor/scripts/ember-latest.js'
handlebars: 'vendor/scripts/handlebars-1.0.rc.3.js'
emblem: 'vendor/scripts/emblem.js'
(if I don't add it I get the compile errors)

And the proper reference as per the documentation in the package file.

Now I'm guessing the .run method is supposed to be declared elsewhere. But I'm having trouble finding what's causing it.

Am I getting the implementation wrong somewhere?

How do you make ember aware of the templates.

What's the recommended way to make ember aware of the templates when using this plugin?

For instance if I have app/templates/application.emblem which contains: {{outlet}}

As well as app/templates/index.emblem which contains some other html.

I would expect that if I require both of those files and do a simple window.App = Em.Application.create(); .
Then visiting the homepage would render the application template with index template inside of it.

So far I've been able to get application template rendering automatically by using:

Ember.TEMPLATES['application'] = require('templates/application'); 

but I haven't been able to get it to also include the index.

Using Ember.TEMPLATES['index'] = require('templates/index'); doesn't seem to do anything.

compile foo.raw.emblem

HI, we have files for raw.emblem format and it don't seem to compile them. Would it be hard to add support for this. or is it supported. e.g. we just need to update our defaultEtension: field.

anyone knows if this still works?

it can't resolve any handlebar variables - eg,

{{outlet}} nothing happens
{{each}} nothing happens
{{myVariable.name}}
and a lot from the emblem examples just won't compile. basically this is unusable at the moment. eg,

11 Dec 06:58:44 - error: Compiling of 'app/templates/application.emblem' failed. TypeError: Object # has no method 'replace'

I'm using these versions if it helps

jquery: 'app/assets/javascripts/jquery-1.9.1.js'
ember: 'app/assets/javascripts/ember-1.0.0-rc.3.js'
handlebars: 'app/assets/javascripts/handlebars-1.0.rc.3.js'

the compiled javascript looks something like this:

data.buffer.push(escapeExpression(helpers._triageMustache.call(depth0, "[object Object].[object Object]", {hash:{},contexts:[depth0],types:["ID"],hashTypes:hashTypes,data:data})));

why is it [object Object].[object Object] shouldn't that be a real javascript object and not a string?

@machty

Block helpers break minified output

Not sure if this is a emblem-brunch or emblem bug.

I have an emblem template with the following snippet:

if profile_pic_url
  img src=profile_pic_url
else
  "No profile pic"

If the application is compiled as usual with brunch build the output works just fine. However, if I compile with brunch build --minify then the output breaks. I get the following error in the browser: Uncaught SyntaxError: Unexpected token in templates.js

Also, if I remove the if blocks, the rest of the emblem template works fine.

I compared the two builds and found the following difference:

Non-Minified

stack1 = helpers['if'].call(depth0, depth0.profile_pic_url, {
    hash: {},
    inverse: self.program(7, program7, data),
    fn: self.program(5, program5, data),
    data: data
});

Minified

stack1 = helpers[ =if].call(depth0, depth0.profile_pic_url, {
    hash: {},
    inverse: self.program(7, program7, data),
    fn: self.program(5, program5, data),
    data: data
});

The helpers[ =if] is what is breaking, as =if is not a valid js statement/token.

Error on compile

With ember last version when I compile with brunch:

SyntaxError: Unexpected token ILLEGAL
    at Contextify.sandbox.run (/Users/.../node_modules/emblem-brunch/node_modules/jsdom/node_modules/contextify/lib/contextify.js:12:24)
    at EmblemCompiler.module.exports.EmblemCompiler.setup (/Users/.../node_modules/emblem-brunch/lib/emblem-brunch.coffee:31:21)
    at new EmblemCompiler (/Users/.../node_modules/emblem-brunch/lib/emblem-brunch.coffee:42:14)
    at /usr/local/lib/node_modules/brunch/lib/watch.js:230:14
    at Array.map (native)
    at getPlugins (/usr/local/lib/node_modules/brunch/lib/watch.js:229:8)
    at initialize (/usr/local/lib/node_modules/brunch/lib/watch.js:279:15)
    at new BrunchWatcher (/usr/local/lib/node_modules/brunch/lib/watch.js:382:7)
    at module.exports.watch (/usr/local/lib/node_modules/brunch/lib/watch.js:421:12)
    at Command.actionHandler (/usr/local/lib/node_modules/brunch/node_modules/commander/index.js:254:8)

Any idea?

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.