module StaticBlocks::SnippetsHelper

Public Instance Methods

s(title, default = nil)
Alias for: snippet_for
snippet_for(title, default = nil) click to toggle source
# File lib/static_blocks/helpers.rb, line 3
def snippet_for(title, default = nil)
  Rails.cache.fetch("snippet::"+I18n.locale.to_s+"::"+title.to_s) do
    snippet = Snippet.published.find_by_title(title.to_s)
    if snippet
      snippet.content
    else
      "Snippet for #{title.to_s} missing"
    end
  end
end
Also aliased as: s
snippet_published?(title) click to toggle source
# File lib/static_blocks/helpers.rb, line 14
def snippet_published?(title)
  Rails.cache.fetch("snippet::"+I18n.locale.to_s+"::"+title.to_s) do
    Snippet.published.find_by_title(title.to_s) || false
  end
end