Sha256: b1a10f65116a80ef1212b83b393c313f50b5c36e5327371c2d758cf1f036768e

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

require 'active_support/hash_with_indifferent_access'

module Annex
  module ViewHelpers
    def annex_block(identifier, opts = {})
      if opts.try(:route)
        route = opts[:route]
        opts[:route].delete
      else
        route = current_route
      end

      doc = Annex::Block.where(:route => route.to_s).first_or_create

      if doc.content
        content = doc.content[identifier.to_s] || ''
      else
        content = ''
      end

      render partial: 'annex/block', locals: { content: content, route: route, identifier: identifier, opts: opts }
    end

    def annex_clips(clip)
      render partial: 'annex/clips'
    end

    def current_route
      "#{I18n.locale}_#{params[:controller]}_#{params[:action]}".to_sym
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
annex-cms-0.1.2 lib/annex/view_helpers.rb
annex-cms-0.1.0 lib/annex/view_helpers.rb