Skip to content

Commit

Permalink
implement my own truncate with plain erb
Browse files Browse the repository at this point in the history
  • Loading branch information
AimeeKnight committed Jun 26, 2014
1 parent dfb3339 commit a64ad27
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/blogament/posts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
</div>
<div class="panel-body">
<blockquote>
<p><%= raw post.text.truncate(50) %></p>
<% if raw(post.text).length >= 40 %>
<p><%= raw post.text.slice(0..40).concat(" ...") %></p>
<% else %>
<p><%= raw post.text %></p>
<% end %>
</blockquote>

<%= raw post.tags.map(&:name).map { |t| link_to t, tag_path(t), class: "label label-default" }.join(' ') %>
Expand Down

0 comments on commit a64ad27

Please sign in to comment.