# How to render template when adding custom route in discourse

**URL:** https://meta.discourse.org/t/how-to-render-template-when-adding-custom-route-in-discourse/64374
**Category:** Development
**Created:** [6월 12, 2017, 6:24오후 UTC](https://meta.discourse.org/t/how-to-render-template-when-adding-custom-route-in-discourse/64374 "2017-06-12T18:24:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [6월 12, 2017, 6:24오후 UTC](https://meta.discourse.org/t/how-to-render-template-when-adding-custom-route-in-discourse/64374/1 "2017-06-12T18:24:22Z")

</div>

I am trying to add a custom route (non-admin route) discourse.

Required route `http://discourse.org/customroute`

I am able to add the route, but the problem is that instead of rendering the template, it just outputs the json text.

 ![](https://global.discourse-cdn.com/meta/original/3X/a/f/afe774ebaf5c9733c232b349136c1aff6215af73.png)

My json data in plugin.rb is

`render json: {title:"custom route"}`

My customroute-map.js.es6 contains

```
export default function() {
  this.resource('customroute', { path: '/customroute' })
}

```

In the route/customroute.js.es6

```
export default Discourse.Route.extend({
   model:function() {
     return ajax('/customroute.json');
   }

```

By doing so, I only get the json data in the template. But the customroute.hbs - handlebar template is not rendered.

I tried using the renderTemplate,

```
 renderTemplate: function() {
      this.render('/customroute');
 }

```

But then I get the error `"Assertion Failed: Cannot call `Ember.get` with an empty string"`

---

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [7월 2, 2017, 3:52오전 UTC](https://meta.discourse.org/t/how-to-render-template-when-adding-custom-route-in-discourse/64374/2 "2017-07-02T03:52:04Z")

</div>

You have to add the template by using

```
Discourse.replaceState(`customroute`)

```

So the route/customroute.js.es6 will be

```
export default Discourse.Route.extend({

  model: function(params) { return params },

  setupController: function(controller, params) {
    ajax(`/customroute.json`).then(function(data) {
      controller.setProperties({ model:data })
      DiscourseURL.replaceState(`/customroute`)
    })
  }
})

```
