machty / emblem-brunch

Emblem.js for Brunch.io
7 stars 13 forks source link

How do you make ember aware of the templates. #1

Closed foxyblocks closed 11 years ago

foxyblocks commented 11 years ago

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.

machty commented 11 years ago

Are you getting any errors in JS inspector in the browser?

foxyblocks commented 11 years ago

No. I have a demo on a branch for a brunch skeleton I've been working on. https://github.com/wordofchristian/brunch-with-hampsters/tree/emblem

Steps:

> git clone https://github.com/wordofchristian/brunch-with-hampsters > cd brunch-with-hampsters > git checkout emblem > npm install && brunch watch --server

open http://localhost:3333

foxyblocks commented 11 years ago

It's possible that the outlet helper isn't functioning and that's why the index isn't being rendered.

I tried adding a linkTo helper to application.emblem:

    li
      linkTo "index"

and I got Uncaught Error: Could not find property 'linkTo'

machty commented 11 years ago

Could you paste the JS inspector output of Ember.TEMPLATES["application"].toString() and Ember.TEMPLATES["index"].toString() ? My hunch is that vanilla handlebars is being used, not emberized handlebars

On Wed, Feb 20, 2013 at 2:51 PM, Christian Schlensker < notifications@github.com> wrote:

It's possible that the outlet helper isn't functioning and that's why the index isn't being rendered.

I tried adding a linkTo helper to application.emblem:

li
  linkTo "index"

and I got Uncaught Error: Could not find property 'linkTo'

— Reply to this email directly or view it on GitHubhttps://github.com/machty/emblem-brunch/issues/1#issuecomment-13852559.

Alex Matchneer Co-Founder and Lead Dev Useful Robot LLC http://usefulrobot.io (614) 395-8832

foxyblocks commented 11 years ago

That's what I was thinking too. Screen Shot 2013-02-20 at 12 23 26 PM

Also here's what's getting compiled and joinedTo app.js

window.require.register("templates/application", function(exports, require, module) {
  module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
    this.compiledVersion = '1.0.rc.2';
  helpers = helpers || Handlebars.helpers; data = data || {};
    var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;

    buffer += "<div class=\"container-fluid\"><div class=\"navbar\"><div class=\"navbar-inner\"><a class=\"brand\">Hampsters</a><ul class=\"nav\"><li class=\"active\"><a>Home</a></li><li></li><li><a>Link</a></li></ul></div></div><p>Find me in <code>app/templates/application.emblem</code>";
    if (stack1 = helpers.outlet) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
    else { stack1 = depth0.outlet; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
    buffer += escapeExpression(stack1)
      + "</p></div>";
    return buffer;
    });
});
window.require.register("templates/index", function(exports, require, module) {
  module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
    this.compiledVersion = '1.0.rc.2';
  helpers = helpers || Handlebars.helpers; data = data || {};

    return "<h1>this is my index</h1>";
    });
});
machty commented 11 years ago

Ok, stay tuned, we're currently taming dependency hell between ember-handlebars, and new releases, and handlebars runtime mismatches. I'll be taking care of this shortly. Sorry for the holdup in the meantime

On Wed, Feb 20, 2013 at 3:26 PM, Christian Schlensker < notifications@github.com> wrote:

That's what I was thinking too. [image: Screen Shot 2013-02-20 at 12 23 26 PM]https://f.cloud.github.com/assets/555044/177613/b010cbfa-7b9b-11e2-8128-227d2fa6f0ff.png

Also here's what's getting compiled and joinedTo app.js

window.require.register("templates/application", function(exports, require, module) { module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compiledVersion = '1.0.rc.2'; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;

buffer += "<div class=\"container-fluid\"><div class=\"navbar\"><div class=\"navbar-inner\"><a class=\"brand\">Hampsters</a><ul class=\"nav\"><li class=\"active\"><a>Home</a></li><li></li><li><a>Link</a></li></ul></div></div><p>Find me in <code>app/templates/application.emblem</code>";
if (stack1 = helpers.outlet) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.outlet; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
  + "</p></div>";
return buffer;
});});window.require.register("templates/index", function(exports, require, module) {

module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compiledVersion = '1.0.rc.2'; helpers = helpers || Handlebars.helpers; data = data || {};

return "<h1>this is my index</h1>";
});});

— Reply to this email directly or view it on GitHubhttps://github.com/machty/emblem-brunch/issues/1#issuecomment-13854400.

Alex Matchneer Co-Founder and Lead Dev Useful Robot LLC http://usefulrobot.io (614) 395-8832

machty commented 11 years ago

Perhaps you could help me out though: one of the major refactors to emblem was to split out Handlebars from it, so that when you compile, you need to provide it the handlebars variant that you're using, either Handlebars or Ember.Handlebars. I'm not certain how to handle these two different cases in a brunch setting; in ember-rails, it assumes Ember.Handlebars, unless the template has .raw.emblem in the name. Would this be consistent with a brunch pattern?

On Wed, Feb 20, 2013 at 3:35 PM, Alex Matchneer machty@gmail.com wrote:

Ok, stay tuned, we're currently taming dependency hell between ember-handlebars, and new releases, and handlebars runtime mismatches. I'll be taking care of this shortly. Sorry for the holdup in the meantime

On Wed, Feb 20, 2013 at 3:26 PM, Christian Schlensker < notifications@github.com> wrote:

That's what I was thinking too. [image: Screen Shot 2013-02-20 at 12 23 26 PM]https://f.cloud.github.com/assets/555044/177613/b010cbfa-7b9b-11e2-8128-227d2fa6f0ff.png

Also here's what's getting compiled and joinedTo app.js

window.require.register("templates/application", function(exports, require, module) { module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compiledVersion = '1.0.rc.2'; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;

buffer += "<div class=\"container-fluid\"><div class=\"navbar\"><div class=\"navbar-inner\"><a class=\"brand\">Hampsters</a><ul class=\"nav\"><li class=\"active\"><a>Home</a></li><li></li><li><a>Link</a></li></ul></div></div><p>Find me in <code>app/templates/application.emblem</code>";
if (stack1 = helpers.outlet) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.outlet; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
  + "</p></div>";
return buffer;
});});window.require.register("templates/index", function(exports, require, module) {

module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compiledVersion = '1.0.rc.2'; helpers = helpers || Handlebars.helpers; data = data || {};

return "<h1>this is my index</h1>";
});});

— Reply to this email directly or view it on GitHubhttps://github.com/machty/emblem-brunch/issues/1#issuecomment-13854400.

Alex Matchneer Co-Founder and Lead Dev Useful Robot LLC http://usefulrobot.io (614) 395-8832

Alex Matchneer Co-Founder and Lead Dev Useful Robot LLC http://usefulrobot.io (614) 395-8832

foxyblocks commented 11 years ago

Check out https://github.com/chrixian/ember-precompiler-brunch

It has you specify the path to ember, handlebars, and jquery so it doesn't have to worry about conflicting dependencies.

I'm currently using it in my master branch https://github.com/wordofchristian/brunch-with-hampsters

You could maybe make the ember dependency optional and only use ember-handlebars when it's provided.

Here's a gist comparing the output of emblem-brunch and ember-precompiler-brunch: https://gist.github.com/wordofchristian/4998646

valpackett commented 11 years ago

+1 for specifying paths

foxyblocks commented 11 years ago

fixed by #2 when that's merged.

machty commented 11 years ago

Just merged #2, can I close this? just need you to run through and see if it's fixed.

foxyblocks commented 11 years ago

Yeah. Looks good now.