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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/trusty_cms/taggable.rb', line 101 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
68 69 70 71 |
# File 'lib/trusty_cms/taggable.rb', line 68 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
59 60 61 62 |
# File 'lib/trusty_cms/taggable.rb', line 59 def inherited(subclass) subclass.tag_descriptions.reverse_merge! self.tag_descriptions super end |
#tag(name, &block) ⇒ Object
73 74 75 76 77 |
# File 'lib/trusty_cms/taggable.rb', line 73 def tag(name, &block) self.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
64 65 66 |
# File 'lib/trusty_cms/taggable.rb', line 64 def tag_descriptions(hash = nil) TrustyCms::Taggable.tag_descriptions[self.name] ||= (hash ||{}) end |
#tags ⇒ Object
79 80 81 |
# File 'lib/trusty_cms/taggable.rb', line 79 def Util.(self.instance_methods) end |