Sha256: 23bb8c5cc3b7d84671a199e320e9ae9b5620f3da8f1f299551b2996c3ff93150

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module Pulitzer
  module PostsHelper

    def link_to_posts(post_type, plural_label, singular_label)
      if post_type.plural?
        link_to plural_label, posts_path(post_type_id: post_type.id)
      else
        link_to singular_label, post_content_elements_path(post_type.singleton_post)
      end
    end

    def link_back_to_posts(post_type, plural_label, singular_label)
      if post_type.plural?
        link_to plural_label, posts_path(post_type_id: post_type.id)
      else
        link_to singular_label, post_types_path
      end
    end

    def render_video(element)
      content_tag(:iframe, nil, src: element.video_link) if element.video_link
    end

    def render_element(element)
      if element.image_type?
        image_tag element.image_url(:thumb)
      elsif element.video_type?
        render_video(element)
      else
        element.body.html_safe if element.body
      end
    end

    def humanize_class_name(klass)
      underscore_class_name(klass).humanize
    end

    def underscore_class_name(klass)
      klass.delete(":").underscore
    end

    def select2_html_options(tag_model)
      { class: 'seletct2-pulitzer-tags', data: { select2_trigger: true } }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pulitzer-0.3.0 app/helpers/pulitzer/posts_helper.rb