Permalink
Browse files

Extract template for episode to separate file

  • Loading branch information...
1 parent f7d9a63 commit c86374ea772ee3d1afebb5c21a994fde0edff1a7 @denis committed Jan 29, 2012
View
@@ -16,17 +16,14 @@
<script src="/javascripts/app/collections/podcasts.js" type="text/javascript"></script>
<script src="/javascripts/app/collections/episodes.js" type="text/javascript"></script>
+ <script src="/javascripts/app/templates/episode_template.js" type="text/javascript"></script>
+
<script src="/javascripts/app/views/podcast_view.js" type="text/javascript"></script>
<script src="/javascripts/app/views/podcasts_view.js" type="text/javascript"></script>
<script src="/javascripts/app/views/episode_view.js" type="text/javascript"></script>
<script src="/javascripts/app/views/episodes_view.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
-
- <script type="text/template" id="episode-template">
- <a href="<%= enclosureUrl %>"><%= title %></a>
- <small><%= published.format("MM/DD/YYYY") %></small>
- </script>
</head>
<body>
@@ -0,0 +1,4 @@
+var EpisodeTemplate = _.template(
+ '<a href="<%= enclosureUrl %>"><%= title %></a> ' +
+ '<small><%= published.format("MM/DD/YYYY") %></small>'
+);
@@ -1,16 +1,15 @@
var EpisodeView = Backbone.View.extend({
tagName: 'li',
className: 'episode',
+ template: EpisodeTemplate,
initialize: function () {
_.bindAll(this, 'render');
this.model.bind('change', this.render);
- this.template = _.template($('#episode-template').html());
},
render: function () {
- var renderedContent = this.template(this.model.toJSON());
- $(this.el).html(renderedContent);
+ $(this.el).html(this.template(this.model.toJSON()));
return this;
}

0 comments on commit c86374e

Please sign in to comment.