Canjs view not rendering data

319 views Asked by At

I'm having a little issue when wanting to render data on one of my ejs views. I send the parameters to the view, but this value is not shown in the view, instead it appears as a blank space.

;(function(namespace, undefined) {
'use strict';

var PageHeader = can.Control({
    defaults: {         
    }
}, {
    'init': function(element, options) {
        var self = this;
        $('body').append( can.view('js/views/header.ejs', {data:  'foo'} ) );
    },
    destroy: function() {
        can.Control.prototype.destroy.call(this);
    }
    /*end of events*/
});
namespace.Controllers = namespace.Controllers || {};
namespace.Controllers.PageHeader = PageHeader; }(this));

//testing view header.ejs
 <div>
      <%= this.data %>
  </div>

The view is render as a blank space, and the object is empty. I'm I missing something, any help is appreciated!

1

There are 1 answers

1
christopherMCA On

As of can 2.0 mustache is the default view renderer and ejs is supported if you add it to your can build. So if your using 2.0 add EJS to the can build as well as in your can.view include the file type (i.e.) can.view('myfile.ejs', data);