Module: Octopress::TagHelpers::ContentFor
- Defined in:
- lib/octopress-tag-helpers/content_for.rb
Class Method Summary collapse
- .append_to_block(context, block, content) ⇒ Object
-
.get_block(context, block) ⇒ Object
Gets the storage space for the content block.
- .get_block_name(tag_name, markup) ⇒ Object
- .render(context, block) ⇒ Object
Class Method Details
.append_to_block(context, block, content) ⇒ Object
22 23 24 25 26 |
# File 'lib/octopress-tag-helpers/content_for.rb', line 22 def self.append_to_block(context, block, content) converter = context.environments.first['converter'] content = converter.convert(content).sub(/\n$/,'') get_block(context, block) << content end |
.get_block(context, block) ⇒ Object
Gets the storage space for the content block
13 14 15 16 |
# File 'lib/octopress-tag-helpers/content_for.rb', line 13 def self.get_block(context, block) context.environments.first['content_for'] ||= {} context.environments.first['content_for'][block] ||= [] end |
.get_block_name(tag_name, markup) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/octopress-tag-helpers/content_for.rb', line 4 def self.get_block_name(tag_name, markup) if markup.strip == '' raise IOError.new "Syntax Error: #{tag_name} requires a name, eg. {% #{tag_name} sidebar %}" else markup.strip end end |
.render(context, block) ⇒ Object
18 19 20 |
# File 'lib/octopress-tag-helpers/content_for.rb', line 18 def self.render(context, block) content = get_block(context, block).map { |b| b }.join end |