Skip to content
Extraits de code Groupes Projets
Valider 5f9c469b rédigé par Dennis Collinson's avatar Dennis Collinson
Parcourir les fichiers

Revert "now using handlebars for client side templates" for now

This reverts commit 4692055d.
parent 4692055d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 20 ajouts et 1597 suppressions
......@@ -3,9 +3,3 @@
- template_name = File.basename(template, ".jst").gsub("_","-")
%script{:id => "#{template_name}-template", :type => 'text/template'}
!= File.read(templates_dir.join(template))
- #don't tell my mom I did this, okay?
- Dir[templates_dir.to_s + "/*.handlebars"].each do |template|
- template_name = File.basename(template, ".handlebars").gsub("_","-")
%script{:id => "#{template_name}-template", :type => 'text/template'}
!= File.read(templates_dir.join(template))
<span class=text>{{ text }}</span>
<span class=text><%= text %></span>
{{#people}}
<a href="/people/{{id}}">
<img class="avatar" src="{{avatar.small}}" title="{{name}}"/>
</a>
{{/people}}
<% _.each(people, function(person) { %>
<a href="/people/<%= person.id %>">
<img class="avatar" src="<%= person.avatar.small %>" title="<%= person.name %>"/>
</a>
<% }) %>
......@@ -9,7 +9,6 @@ javascripts:
main:
- public/javascripts/vendor/underscore.js
- public/javascripts/vendor/backbone.js
- public/javascripts/vendor/handlebars-1.0.0.beta.6.js
- public/javascripts/vendor/markdown/*
- public/javascripts/app/app.js
- public/javascripts/app/helpers/*
......
......@@ -22,18 +22,9 @@ app.views.Base = Backbone.View.extend({
},
renderTemplate : function(){
var templateHTML //don't forget to regenerate your jasmine fixtures ;-)
var templateHTML = $(this.template_name).html(); //don't forget to regenerate your jasmine fixtures ;-)
this.template = _.template(templateHTML);
var presenter = _.isFunction(this.presenter) ? this.presenter() : this.presenter
if(this.legacyTemplate) {
templateHTML = $(this.template_name).html();
this.template = _.template(templateHTML);
} else {
window.templateCache = window.templateCache || {}
templateHTML = $("#" + this.templateName + "-template").html(); //don't forget to regenerate your jasmine fixtures ;-)
this.template = templateCache[this.templateName] = templateCache[this.templateName] || Handlebars.compile(templateHTML);
}
$(this.el).html(this.template(presenter));
this.postRenderTemplate();
},
......
app.views.Comment = app.views.Content.extend({
legacyTemplate : true,
template_name: "#comment-template",
tagName : "li",
......
app.views.CommentStream = app.views.Base.extend({
legacyTemplate : true,
template_name: "#comment-stream-template",
className : "comment_stream",
......
app.views.Content = app.views.StreamObject.extend({
legacyTemplate : true,
presenter : function(){
var model = this.model
return _.extend(this.defaultPresenter(), {
......
app.views.Feedback = app.views.StreamObject.extend({
legacyTemplate : true,
template_name: "#feedback-template",
className : "info",
......
app.views.Header = app.views.Base.extend({
legacyTemplate : true,
template_name : "#header-template",
......
app.views.LikesInfo = app.views.StreamObject.extend({
legacyTemplate : true,
template_name : "#likes-info-template",
className : "likes_container",
events : {
"click .expand_likes" : "showAvatars"
"click .expand_likes" : "showAvatars"
},
tooltipSelector : ".avatar",
......@@ -16,12 +15,12 @@ app.views.LikesInfo = app.views.StreamObject.extend({
},
showAvatars : function(evt){
if(evt) { evt.preventDefault() }
var self = this;
this.model.likes.fetch()
.done(function(resp){
if(evt) { evt.preventDefault() }
var self = this;
this.model.likes.fetch()
.done(function(resp){
// set like attribute and like collection
self.model.set({likes : self.model.likes.reset(resp)})
})
}
})
}
});
app.views.Post = app.views.StreamObject.extend({
legacyTemplate : true,
template_name: "#stream-element-template",
......@@ -29,14 +28,11 @@ app.views.Post = app.views.StreamObject.extend({
//subviews
this.commentStreamView = new app.views.CommentStream({ model : this.model});
this.likesInfoView = new app.views.LikesInfo({ model : this.model});
return this;
},
likesInfoView : function(){
return new app.views.LikesInfo({ model : this.model});
},
feedbackView : function(){
if(!window.app.user().current_user ) { return null }
return new app.views.Feedback({model : this.model});
......
app.views.StreamFaces = app.views.Base.extend({
templateName : "stream-faces",
template_name : "#stream-faces-template",
className : "stream-faces",
......
app.views.Stream = Backbone.View.extend({
legacyTemplate : true,
events: {
"click #paginate": "render"
},
......
Ce diff est replié.
describe("app.views.Base", function(){
describe("#render", function(){
beforeEach(function(){
var staticTemplateClass = app.views.Base.extend({ templateName : "static-text" })
var staticTemplateClass = app.views.Base.extend({ template_name : "#static-text-template" })
this.model = new Backbone.Model({text : "model attributes are in the default presenter"})
this.view = new staticTemplateClass({model: this.model})
......@@ -21,7 +21,7 @@ describe("app.views.Base", function(){
context("subViewRendering", function(){
beforeEach(function(){
var viewClass = app.views.Base.extend({
templateName : "static-text",
template_name : "#static-text-template",
subviews : {
".subview1": "subview1",
".subview2": "createSubview2"
......
......@@ -26,7 +26,6 @@ src_files:
- public/javascripts/jquery.infieldlabel-custom.js
- public/javascripts/vendor/underscore.js
- public/javascripts/vendor/backbone.js
- public/javascripts/vendor/handlebars-1.0.0.beta.6.js
- public/javascripts/fileuploader-custom.js
- public/javascripts/jquery.autocomplete-custom.js
- public/javascripts/diaspora.js
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter