lundi 21 décembre 2015

{{link-to}} within a model's attribute?

Given something like a post model with a body attribute, is there a way to get ember to dynamically render {{link-to}}'s within the body attribute?

Example:

// The model
post = {
  body: `
    {{#link-to "posts.index"}}
      <h1>The "{{#link-to}}" is rendered literally!</h1>
    {{/link-to}}`
}

// The .hbs file
<div class="container">
  {{postBody post.body}}
</div>

// Helper function to avoid escaping the HTML
export function postBody(postBody) {
  return Ember.String.htmlSafe(postBody);
}
export default Ember.Helper.helper(postBody);

The only thing I can think to do is enter a static link, which would cause a full page reload.




Aucun commentaire:

Enregistrer un commentaire