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

Dynamically-added angle bracket components aren't recognized #11649

Closed
courthead opened this issue Jul 4, 2015 · 8 comments
Closed

Dynamically-added angle bracket components aren't recognized #11649

courthead opened this issue Jul 4, 2015 · 8 comments

Comments

@courthead
Copy link

http://emberjs.jsbin.com/zahucoyara/edit?html,css,js,output

I have a component that builds a property that's a string with some angle-bracket components inside of it. The string is printed unescaped in the component's template. I would expect Handlebars to recognize the angle-bracket components, however they are treated as normal HTML tags. I'm not sure if this is a bug, if I'm doing something wrong, or if this functionality just isn't supported yet. I've attached a JSBin showing a potential use-case and the issue.

@stefanpenner
Copy link
Member

Ya. This isn't something we support, I also suspect we won't as t would require all of the htmlbars compiler client side and would likely be pretty slow. If you wish to add components dynamically. The component helper may be your best bet.

You may also want to look at the context component rfc

@courthead
Copy link
Author

@stefanpenner Okay makes sense, thanks for the response. I'll take a look at the context component RFC! Also, pre-glimmer, I was able to do something like this successfully:

App.SomeThingComponent = Ember.Component.reopen({
  _updateLayout: function () {
    const templateStr = '{{some-other-thing value="' + whatever + '"}}';
    const newTemplate = Ember.Handlebars.compile(templateStr);
    this.set('layout', newTemplate).rerender();
  }.observes('whatever').on('init')
});

Post-Glimmer, this still works on initialization. However, when whatever is changed and the function is run again, nothing is updated in the UI after the rerender call. Is this a regression or an intentional side effect of Glimmer?

Thanks again!

@stefanpenner
Copy link
Member

Also, pre-glimmer, I was able to do something like this successfully:

Just so you know, running the compiler in production really isn't something I would at all recommend. In-fact I would strongly advise against it.

I am unclear if this particular approach is ever something we intended to support.

this.set('layout', newTemplate).rerender();

that being said, i suspect this line is the issue, are your trying to call rerender on the template or on the component?

@courthead
Copy link
Author

The intention is to call rerender on the component after changing its layout. I'll see if I can come up with an alternative approach that doesn't use the compiler. It was slow, but acceptably slow. Worst-case scenario I'll just do the highlighting by modifying the DOM directly instead of using a component.

@rwjblue
Copy link
Member

rwjblue commented Jul 4, 2015

In 1.13 it is not possible to change layout after initial render. There is at least one issue open about this...

@courthead
Copy link
Author

Got it, thanks, I'll follow those issues

@rwjblue
Copy link
Member

rwjblue commented Jul 5, 2015

#11315 is a failing test for rerendering after updating layout.

@rwjblue
Copy link
Member

rwjblue commented Apr 18, 2016

Closing in favor of the failing test case PR mentioned above.

@rwjblue rwjblue closed this as completed Apr 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants