I have a backed api to get a html file content(eg-

I have a backed api to get a html file content(eg-
Hi @light44 could you describe your use case a little more (maybe some snippets or sample requests?) and code format the e.g. you posted above?
Rendering HTML in ember is pretty easy with handlebars (though I wouldnât describe it as a super common use case) but as for whether youâll want to use ember data (and therefore an adapter) to fetch the html is a different question. Really depends on your use case and what the content looks likeâŚ
I have done what you describe, itâs a pretty reasonable strategy for incrementally adopting Ember.
Assuming you have a server somewhere that gives you HTML and you want to drop that HTML inside an Ember template, you can
model
hook, get the HTML, something like:model() {
return fetch('/your.html').then(response => response.text()).then(html => {
// this object is the "model" in your template
return {
html
};
});
}
The server said: {{{model.html}}}
If the server response is a complete page with <head>
and <body>
, you may want to strip those parts out of the HTML, since that wonât be valid HTML inside your existing <body>
.
Thanks it workedđ sorry for the late reply