# coding: UTF-8 # DOC: # We use Helper Methods for tree building, # because it's faster than View Templates and Partials # SECURITY note # Prepare your data on server side for rendering # or use h.html_escape(node.content) # for escape potentially dangerous content module RenderCommentsTreeHelper module Render class << self attr_accessor :h, :options # Main Helpers def controller @options[:controller] end def t str controller.t str end # Render Helpers def visible_draft? controller.try(:comments_view_token) == @comment.view_token end def moderator? controller.try(:current_user).try(:comments_moderator?, @comment) end # Render Methods def render_node(h, options) @h, @options = h, options @comment = options[:node] @max_reply_depth = options[:max_reply_depth] || TheComments.config.max_reply_depth if @comment.draft? draft_comment else @comment.published? published_comment end end def draft_comment if visible_draft? || moderator? published_comment else "
#{ t('the_comments.reply') }" end end def controls "