In my template I have to put this.name and this.gravatar to access my user model data attributes. If I don't I get an error message when the template attempts to render. Everything works but I don't see any examples where they put this. in the templates.
My Backbone View:
Class MyApp.Views.Header extends Backbone.View
template: JST['header']
initialize: =>
@model.on("change reset add", @render)
render: =>
@$el.html(@template (@model.attributes) )
this
My Header Template:
<span id= "headerRight">
<span>
<a href="/classroom/help">Help</a>
</span>
<span> <img id="headerGravatar" src="<%= this.gravatar %>"></span>
<span> <%= this.name %> </span>
<span>
<a class="logout" href='/signout'>Sign Out</a>
</span>
</span>
How I generate my view:
headerView = new UCBCloudClassroom.Views.Header( model: @user)
$('#header').html(headerView.render().el)
Backbone requires underscore so most of the examples you see will use underscore templates which have the <%= property %> syntax.
Eco templates use the <%= @property %> syntax for displaying model attributes link:
Since <%= @property %> is equivalent to <%= this.property %> everything is working as intended.