3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/helpers/blocky_helper.rb', line 3
def blocky(block_name, options={}, &block)
page_path = options[:global] ? nil : request.path
content_block = Blocky::ContentBlock.where({
page_path: page_path,
name: block_name
}).first_or_initialize
if content_block.new_record?
if block_given?
content_block.content = capture(&block)
end
content_block.save
end
Rails.cache.fetch(content_block, skip_digest: options[:global]) do
raw(content_block.content)
end
end
|