Sha256: 4ca73962de6cad5b3ace53485e95426325d27f5132f56d01a8c060d0846c1ec1
Contents?: true
Size: 858 Bytes
Versions: 1
Compression:
Stored size: 858 Bytes
Contents
module PufferPages module Liquid module Tags class RenderSnippet < ::Liquid::Tag Syntax = /(#{::Liquid::QuotedFragment}+)/ def initialize(tag_name, markup, tokens) if markup =~ Syntax @name = $1 else raise SyntaxError.new("Syntax Error in 'render_snippet' - Valid syntax: render_snippet snipper_name") end super end def render(context) name = context[@name] snippet = Snippet.find_by_name(name) if snippet snippet.render(context) else raise ArgumentError.new("Argument error in 'render_snippet' - Can not find snippet named '#{name}'") end end end end end end Liquid::Template.register_tag('render_snippet', PufferPages::Liquid::Tags::RenderSnippet)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
puffer_pages-0.0.7 | lib/puffer_pages/liquid/tags/render_snippet.rb |