Sha256: 7c8a80cf195e74e1cc9e5cdb6c8a005d9c10b4b128902ea9e584aeed0d11f076

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

module StaticBlocks
  module StaticBlocksHelper
    def static_block_for(name, default = nil)
      Rails.cache.fetch("static_block::"+I18n.locale.to_s+"::"+name.to_s) do
        static_block = StaticBlock.published.find_by_title(name.to_s)
        if static_block
          static_block.content
        else
          "StaticBlock for #{name.to_s} missing"
        end
      end
    end

    def static_block_published?(name)
      Rails.cache.fetch("static_block::"+I18n.locale.to_s+"::"+name.to_s) do
        StaticBlock.published.find_by_title(name.to_s) || false
      end
    end

    alias_method :s, :static_block_for
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
static_blocks-0.1.0 lib/static_blocks/helpers.rb