aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2013-12-23 17:07:37 +0100
committerHarald Eilertsen <haraldei@anduin.net>2013-12-23 17:07:37 +0100
commit3fb85eff8510ef7d5505924805cabde0edcebef3 (patch)
treecaef55a987f44de3d900d18159b9e78964e4ca99
parente6c75a021441316ff1a1e0c9f2e9d5b027412a32 (diff)
downloadhmnoweb-3fb85eff8510ef7d5505924805cabde0edcebef3.tar.gz
hmnoweb-3fb85eff8510ef7d5505924805cabde0edcebef3.tar.bz2
hmnoweb-3fb85eff8510ef7d5505924805cabde0edcebef3.zip
Move markup from decorator to template.
Note to self, use model decorators to massage model data, but leave the markup to the views where it belong.
-rw-r--r--app/decorators/models/sidebar_post_decorator.rb9
-rw-r--r--app/views/common/_sidebar_module.html.erb6
2 files changed, 4 insertions, 11 deletions
diff --git a/app/decorators/models/sidebar_post_decorator.rb b/app/decorators/models/sidebar_post_decorator.rb
index c6f10d5..93353bb 100644
--- a/app/decorators/models/sidebar_post_decorator.rb
+++ b/app/decorators/models/sidebar_post_decorator.rb
@@ -1,18 +1,11 @@
require 'delegate'
class SidebarPostDecorator < SimpleDelegator
- include ActionView::Helpers::TagHelper
- include ActionView::Helpers::TextHelper
-
def initialize(post)
super(post)
end
- def title
- content_tag(:h2, link_to(super, __getobj__.friendly_id))
- end
-
def body
- content_tag(:div, sanitize(truncate(super, :length => 32, :separator => ' ')))
+ super.truncate(64)
end
end
diff --git a/app/views/common/_sidebar_module.html.erb b/app/views/common/_sidebar_module.html.erb
index 41f51e7..73554b7 100644
--- a/app/views/common/_sidebar_module.html.erb
+++ b/app/views/common/_sidebar_module.html.erb
@@ -1,9 +1,9 @@
<% modules.keys.each do |c| -%>
<div class="sidebar_content">
<h1><%= c %></h1>
- <%- modules[c].each do |entry| %>
- <%= entry.title %>
- <%= entry.body %>
+ <%- modules[c].each do |item| %>
+ <h2><%= link_to(item.title, item.friendly_id) %></h2>
+ <div><%= item.body %></div>
<% end %>
</div>
<% end -%>