Module: BlogHelper

Defined in:
app/helpers/blog_helper.rb

Overview

View helper: blog.

Instance Method Summary collapse

Instance Method Details

#post_title(post) ⇒ String

Renders a linked, truncated blog post title.

Parameters:

  • post (Post)

    the blog post to link to

Returns:

  • (String)

    HTML link to the post, with the title truncated to 66 characters



8
9
10
# File 'app/helpers/blog_helper.rb', line 8

def post_title(post)
  link_to post.title[0..65], post_path(post)
end

Renders a comma-separated list of links for a post's recognized tags.

Only tags included in Post::POST_TAGS are rendered; each links to the
tag's CMS archive page.

Parameters:

  • post (Post)

    the blog post whose tags are rendered

Returns:

  • (ActiveSupport::SafeBuffer)

    HTML-safe list of tag links joined by ", "

See Also:



20
21
22
23
24
# File 'app/helpers/blog_helper.rb', line 20

def tags_with_links(post)
  post.tags.select { |t| t.in?(Post::POST_TAGS) }.map do |t|
    link_to Post.tag_title(t), cms_link("/posts/#{t}/tag")
  end.join(', ').html_safe
end