Module: ChiliProject::Liquid::Tags

Defined in:
lib/chili_project/liquid/tags/tag.rb,
lib/chili_project/liquid/tags.rb,
lib/chili_project/liquid/tags/include.rb,
lib/chili_project/liquid/tags/identity.rb,
lib/chili_project/liquid/tags/child_pages.rb,
lib/chili_project/liquid/tags/hello_world.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Defined Under Namespace

Classes: ChildPages, HelloWorld, Identity, Include, Tag, TagError

Class Method Summary collapse

Class Method Details

.register_tag(name, klass, options = {}) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/chili_project/liquid/tags.rb', line 19

def self.register_tag(name, klass, options={})
  if options[:html]
    html_class = Class.new do
      def render(context)
        result = @tag.render(context)
        context.html_result(result)
      end

      def method_missing(*args, &block)
        @tag.send(*args, &block)
      end
    end
    html_class.send :define_method, :initialize do |*args|
      @tag = klass.new(*args)
    end
    ::Liquid::Template.register_tag(name, html_class)
  else
    ::Liquid::Template.register_tag(name, klass)
  end
end