Sha256: 65c6faa5a0d93ec5920578fa0656a19b238ab842bcb2c13f285c5232a5f4bbbc
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
# Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks # module Octopress module Tags class WrapTag < Liquid::Block def initialize(tag_name, markup, tokens) super @og_markup = @markup = markup @tag_name = tag_name end def render(context) require 'pry-debugger' markup = Helpers::Conditional.parse(@markup, context) return unless markup case @tag_name when 'wrap_yield' content = Tags::YieldTag.new('yield', markup, []).render(context) when 'wrap_render' begin content = Tags::RenderTag.new('render', markup, []).render(context) rescue => error error_msg error end when 'wrap' begin content = Tags::IncludeTag.new('include', markup, []).render(context) rescue => error error_msg error end end # just in case yield had a value old_yield = context.scopes.first['yield'] context.scopes.first['yield'] = content content = super.strip context.scopes.first['yield'] = old_yield content end def error_msg(error) error.message message = "Wrap failed: {% #{@tag_name} #{@og_markup}%}." message << $1 if error.message =~ /%}\.(.+)/ raise IOError.new message end def content_for(markup, context) @block_name = Helpers::ContentFor.get_block_name(@tag_name, markup) Helpers::ContentFor.render(context, @block_name).strip end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
octopress-ink-1.0.0.alpha.27 | lib/octopress-ink/tags/wrap.rb |