Sha256: 313288c8ed0fe247240c797ea6bb7cb2389ca051b80552c6e87a154bae28d494

Contents?: true

Size: 835 Bytes

Versions: 14

Compression:

Stored size: 835 Bytes

Contents

module Cmor
  module Blog
    # Example:
    #
    #     # app/controllers/application_controller.rb
    #     class ApplicationController < ActionController::Base
    #       view_helper Cmor::Blog::ApplicationViewHelper, as: :blog_helper
    #     end
    #
    class ApplicationViewHelper < Rao::ViewHelper::Base
      # Example:
      #
      #     # app/views/layouts/application.html.haml
      #     = blog_helper(self).render_recent_posts(3)
      #
      def render_recent_posts(count)
        posts = Cmor::Blog::Post.published.for_locale.limit(count).all
        c.render html: posts.collect { |p| render_post(p.id) }.join("<hr />").html_safe
      end

      def render_post(id)
        post = Cmor::Blog::Post.published.for_locale.where(id: id).first
        render(post: post) if post.present?
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cmor_blog-0.0.60.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.59.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.58.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.57.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.56.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.55.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.54.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.53.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.52.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.51.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.50.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.49.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.48.pre app/view_helpers/cmor/blog/application_view_helper.rb
cmor_blog-0.0.45.pre app/view_helpers/cmor/blog/application_view_helper.rb