Module: TrustyCms::Taggable::ClassMethods
- Defined in:
- lib/trusty_cms/taggable.rb
Instance Method Summary collapse
-
#deprecated_tag(name, options = {}, &dblock) ⇒ Object
Define a tag while also deprecating it.
- #desc(text) ⇒ Object
- #inherited(subclass) ⇒ Object
- #tag(name, &block) ⇒ Object
- #tag_descriptions(hash = nil) ⇒ Object
- #tags ⇒ Object
Instance Method Details
#deprecated_tag(name, options = {}, &dblock) ⇒ Object
Define a tag while also deprecating it. Normal usage:
deprecated_tag 'old:way', :substitute => 'new:way', :deadline => '1.1.1'
If no substitute is given then a warning will be issued but nothing rendered. If a deadline version is provided then it will be mentioned in the deprecation warnings.
In less standard situations you can use deprecated_tag in exactly the same way as tags are normally defined:
desc %
Please note that the old r:busted namespace is no longer supported.
Refer to the documentation for more about the new r:hotness tags.
deprecated_tag ‘busted’ do |tag|
raise TagError "..."
end
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/trusty_cms/taggable.rb', line 105 def deprecated_tag(name, = {}, &dblock) TrustyCms::Taggable.tag_deprecations[name] = .dup if dblock tag(name) do |tag| warn_of_tag_deprecation(name, ) dblock.call(tag) end else tag(name) do |tag| warn_of_tag_deprecation(name, ) tag.render([:substitute], tag.attr.dup, &tag.block) if [:substitute] end end end |
#desc(text) ⇒ Object
72 73 74 75 |
# File 'lib/trusty_cms/taggable.rb', line 72 def desc(text) TrustyCms::Taggable.last_description = text # TrustyCms::Taggable.last_description = RedCloth.new(Util.strip_leading_whitespace(text)).to_html end |
#inherited(subclass) ⇒ Object
63 64 65 66 |
# File 'lib/trusty_cms/taggable.rb', line 63 def inherited(subclass) subclass.tag_descriptions.reverse_merge! tag_descriptions super end |
#tag(name, &block) ⇒ Object
77 78 79 80 81 |
# File 'lib/trusty_cms/taggable.rb', line 77 def tag(name, &block) tag_descriptions[name] = TrustyCms::Taggable.last_description if TrustyCms::Taggable.last_description TrustyCms::Taggable.last_description = nil define_method("tag:#{name}", &block) end |
#tag_descriptions(hash = nil) ⇒ Object
68 69 70 |
# File 'lib/trusty_cms/taggable.rb', line 68 def tag_descriptions(hash = nil) TrustyCms::Taggable.tag_descriptions[name] ||= (hash || {}) end |
#tags ⇒ Object
83 84 85 |
# File 'lib/trusty_cms/taggable.rb', line 83 def Util.(instance_methods) end |