Module: TrustyCms::Taggable

Included in:
DeprecatedTags, NestedLayouts::Tags::Core, Page, StandardTags
Defined in:
lib/trusty_cms/taggable.rb

Defined Under Namespace

Modules: ClassMethods, Util

Constant Summary collapse

@@tag_descriptions =
{}
@@tag_deprecations =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/trusty_cms/taggable.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
  base.module_eval do
    def self.included(new_base)
      super
      new_base.class_eval do
        include Rails.application.routes.url_helpers
      end
      class << new_base
        def default_url_options
          {:controller => "site", :action => "show_page", :only_path => true}
        end
      end
      new_base.tag_descriptions.merge! self.tag_descriptions
    end

    protected
      def params
        @params ||= request.parameters unless request.nil?
      end

      def request_uri
        @request_url ||= request.request_uri unless request.nil?
      end
  end
end

Instance Method Details

#render_tag(name, tag_binding) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/trusty_cms/taggable.rb', line 33

def render_tag(name, tag_binding)
  tag_method_name = "tag:#{name}"
  tag_method = method(tag_method_name)
  if tag_method.arity == 0
    tag_method.call
  else
    tag_method.call tag_binding
  end
end

#tag_descriptions(hash = nil) ⇒ Object



47
48
49
# File 'lib/trusty_cms/taggable.rb', line 47

def tag_descriptions(hash=nil)
  self.class.tag_descriptions hash
end

#tagsObject



43
44
45
# File 'lib/trusty_cms/taggable.rb', line 43

def tags
  Util.tags_in_array(methods)
end

#warn_of_tag_deprecation(tag_name, options = {}) ⇒ Object



51
52
53
54
55
56
# File 'lib/trusty_cms/taggable.rb', line 51

def warn_of_tag_deprecation(tag_name, options={})
  message = "Deprecated radius tag <r:#{tag_name}>"
  message << " will be removed or significantly changed in radiant #{options[:deadline]}." if options[:deadline]
  message << " Please use <r:#{options[:substitute]}> instead." if options[:substitute]
  ActiveSupport::Deprecation.warn(message)
end