Sha256: 3746e541e390d9847b48b5e43f419408c9253039fb08d74c26bbaf9c103e5c0e

Contents?: true

Size: 592 Bytes

Versions: 3

Compression:

Stored size: 592 Bytes

Contents

module StaticBlocks
  module StaticBlocksHelper
    def static_block_for(name, default = nil)
      Rails.cache.fetch("static_block::"+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::"+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

3 entries across 3 versions & 1 rubygems

Version Path
static_blocks-0.0.5 lib/static_blocks/helpers.rb
static_blocks-0.0.4 lib/static_blocks/helpers.rb
static_blocks-0.0.3 lib/static_blocks/helpers.rb