Render comment partial with collection option
This commit is contained in:
parent
0f6b322333
commit
03e3c3a202
4 changed files with 6 additions and 17 deletions
|
|
@ -26,10 +26,10 @@ class CommentsController < ApplicationController
|
|||
:comment_id => @comment.id,
|
||||
:html => render_to_string(
|
||||
:partial => 'comments/comment',
|
||||
:locals => {
|
||||
:locals => { :hash => {
|
||||
:comment => @comment,
|
||||
:person => current_user,
|
||||
}
|
||||
}}
|
||||
)
|
||||
}
|
||||
render(:json => json, :status => 201)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module SocketsHelper
|
|||
elsif object.is_a? Person
|
||||
v = render_to_string(:partial => type_partial(object), :locals => {:single_aspect_form => opts[:single_aspect_form], :person => object, :aspects => user.aspects, :current_user => user})
|
||||
elsif object.is_a? Comment
|
||||
v = render_to_string(:partial => 'comments/comment', :locals => {:comment => object, :person => object.person})
|
||||
v = render_to_string(:partial => 'comments/comment', :locals => {:hash => {:comment => object, :person => object.person}})
|
||||
else
|
||||
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- comment = hash[:comment]
|
||||
- person = hash[:person]
|
||||
%li.comment{:data=>{:guid=>comment.id}}
|
||||
%a{:href => "/people/#{person.id}"}
|
||||
%img{:src => image_or_default(person), :class => "avatar", :alt => person.real_name, :title => person.real_name, "data-person_id" => person.id}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,7 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
%ul.comments{:id => post_id, :class => ("hidden" if comment_hashes.size == 0)}
|
||||
- for comment_hash in comment_hashes
|
||||
-comment = comment_hash[:comment]
|
||||
-person = comment_hash[:person]
|
||||
|
||||
%li.comment{:data=>{:guid=>comment.id}}
|
||||
%a{:href => "/people/#{person.id}"}
|
||||
%img{:src => image_or_default(person), :class => "avatar", :alt => person.real_name, :title => person.real_name, "data-person_id" => person.id}
|
||||
.content
|
||||
.from
|
||||
%a{:href => "/people/#{person.id}"}=person.real_name
|
||||
= markdownify(comment.text, :youtube_maps => comment[:youtube_titles])
|
||||
%div.time
|
||||
= comment.created_at ? "#{time_ago_in_words(comment.created_at)}" : Time.now
|
||||
= render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash
|
||||
%li.comment.show
|
||||
= render 'comments/new_comment', :post_id => post_id
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue