Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New line being inserted after a component (when pre-compiled?) #3715

Closed
chancancode opened this issue Nov 8, 2013 · 9 comments
Closed

New line being inserted after a component (when pre-compiled?) #3715

chancancode opened this issue Nov 8, 2013 · 9 comments
Labels

Comments

@chancancode
Copy link
Member

I'm pretty sure this is not the right project to report this bug, but since it cuts across ember, ember rails and handlebars, I need some help triaging this.

In this you can see that everything is working fine:

[There shouldn't be any space in "here"...]

However, in this equivalent ember-rails app (source) a newline is beings inserted after each component call:

[There shouldn't be any space in "here
"...
]

Inspecting the source it seems to be coming from here:

Ember.TEMPLATES["components/my-component"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
  var buffer = '', hashTypes, hashContexts, escapeExpression=this.escapeExpression;


  hashTypes = {};
  hashContexts = {};
  data.buffer.push(escapeExpression(helpers._triageMustache.call(depth0, "yield", {hash:{},contexts:[depth0],types:["ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data})));
  data.buffer.push("\n"); // <---- THIS
  return buffer;

});

I'm unsure if this is a handlebars compiler bug, an ember bug or an ember-rails bug. Some help in getting this to the right hands would be appreciated. (The bug prevents components from being used inside any whitespace sensitive context.)

@rwjblue
Copy link
Member

rwjblue commented Nov 9, 2013

The rails app template ends with a new line. That is where it is coming from. I do not think this is a bug...

@chancancode
Copy link
Member Author

@rjackson: Nope, at least I don't intend it to end with one, so if ember-rails thinks it ends with a newline, it's probably a bug with ember-rails

@wagenet
Copy link
Member

wagenet commented Nov 9, 2013

It's unclear where this is coming from, but it does seem like a bug.

@chancancode
Copy link
Member Author

I tried reproducing this with ember app kit, but it doesn't seem to be affected. So that probably narrows it down to rails (sprocket..?) or ember-rails

@chancancode
Copy link
Member Author

Found it! It's added by sprockets. The code has been around since forever and no one seems to know why. There's a related issue @ leshill/handlebars_assets#81.

I'm unsure what to do at this point, @rjackson what do you think? Ideally we should fix sprockets itself but it doesn't look like it's going to happen anytime soon...

@chancancode
Copy link
Member Author

By the way, in case you are wondering, yes - this is a real issue affecting our code, we are using components inside a whitespace sensitive context, and right now the workaround is to override render and trim the newline from the buffer =/ So I really hope this will get fixed one way or the other (work around sprockets in ember-rails, really push for a fix in sprockets, or whatever). I'm totally willing to help, but I want to get people's opinion on the best/preferred course of action here

@wagenet
Copy link
Member

wagenet commented Nov 15, 2013

@chancancode Sorry about this. We don't control sprockets so there's not much we can do. It's possible ember-rails can manage a workaround, but the real fix is going to be with sprocket.

@wagenet wagenet closed this as completed Nov 15, 2013
@rwjblue
Copy link
Member

rwjblue commented Nov 15, 2013

The only solution that I can think of for now is to manually include the template into actual HTML output. This kinda SUCKS, but it should work...

@chancancode
Copy link
Member Author

@wagenet yes, that makes sense, it's not an ember issue for sure. @rjackson, I'll see if I can get this fixed in sprockets. Do you want an issue on ember-rails to track this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants