# Ember adapter to get a html file (may contain css,js) and then render the file on a template

**URL:** <https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678>\
**Category:** Ember Data\
**Created:** [October 19, 2018, 7:22am UTC](https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678 "2018-10-19T07:22:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![light44](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/light44/32/16828_2.png) [@light44](https://discuss.emberjs.com/u/light44)\
**Post date:** [October 19, 2018, 7:22am UTC](https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678/1 "2018-10-19T07:22:27Z")

</div>

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

Somethings
). My question is where and how to store this html , so that i can able to render the html on the hbs template. I am new to ember Universe so please be kind.😄

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [October 19, 2018, 2:25pm UTC](https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678/2 "2018-10-19T14:25:38Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [October 19, 2018, 3:25pm UTC](https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678/3 "2018-10-19T15:25:58Z")

</div>

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

1. In your route’s `model` hook, get the HTML, something like:

```auto
model() {
  return fetch('/your.html').then(response => response.text()).then(html => {
     // this object is the "model" in your template
    return {
       html
    };
  });
}

```

1. Render the HTML in a template via triple curlies:

```auto
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>`.

---

<div class="post-metadata">

**Author:** ![light44](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/light44/32/16828_2.png) [@light44](https://discuss.emberjs.com/u/light44)\
**Post date:** [March 6, 2019, 3:38am UTC](https://discuss.emberjs.com/t/ember-adapter-to-get-a-html-file-may-contain-css-js-and-then-render-the-file-on-a-template/15678/4 "2019-03-06T03:38:44Z")

</div>

Thanks it worked👍 sorry for the late reply
