Module: BBTagCloser
- Defined in:
- lib/bb_tag_closer.rb,
lib/bb_tag_closer/railtie.rb,
lib/bb_tag_closer/version.rb
Defined Under Namespace
Modules: ClassMethods Classes: Configuration, Railtie
Constant Summary collapse
- VERSION =
"1.0.3"
Instance Attribute Summary collapse
-
#font_color ⇒ Object
Returns the value of attribute font_color.
-
#font_size ⇒ Object
Returns the value of attribute font_size.
Class Method Summary collapse
-
.configure {|BBTagCloser::Configuration| ... } ⇒ Object
Sets configuration options.
- .included(base) ⇒ Object
Instance Method Summary collapse
-
#close_bb_tags ⇒ Object
Called during a callback specified in the :on paramater in close_tags or close_tags_for.
Instance Attribute Details
#font_color ⇒ Object
Returns the value of attribute font_color.
7 8 9 |
# File 'lib/bb_tag_closer.rb', line 7 def font_color @font_color end |
#font_size ⇒ Object
Returns the value of attribute font_size.
6 7 8 |
# File 'lib/bb_tag_closer.rb', line 6 def font_size @font_size end |
Class Method Details
.configure {|BBTagCloser::Configuration| ... } ⇒ Object
Sets configuration options. Currently supports setting of custom bb_tags through BBTagCloser.configure {|config| config.bb_tags = [“u”, “b”, “s”, “i”, “quote”, “url”, “img”, “email”, “youtube”, “size”, “color”, # additional tags ]}
63 64 65 |
# File 'lib/bb_tag_closer.rb', line 63 def self.configure(&block) yield BBTagCloser::Configuration end |
.included(base) ⇒ Object
10 11 12 13 |
# File 'lib/bb_tag_closer.rb', line 10 def self.included(base) base.attr_accessible :font_size, :font_color base.extend ClassMethods end |
Instance Method Details
#close_bb_tags ⇒ Object
Called during a callback specified in the :on paramater in close_tags or close_tags_for. Closes forum tags in the opposite order they were added by the user.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bb_tag_closer.rb', line 69 def text_attributes = self.class.taggable_fields text_attributes.each do |attribute| = send(attribute).scan(Regexp.new "\\[(.*?)\\]").flatten.delete_if {|c| c.include? "/"}.map {|i| i.include?("=") ? i.slice(Regexp.new "(.*)\\=").chomp("=") : i}.reverse.map(&:downcase).delete_if { |x| not Configuration..include? x } .each do |tag| = send(attribute).downcase.scan(Regexp.new "\\[#{tag}=").length + send(attribute).downcase.scan(Regexp.new "\\[#{tag}\\]").length = send(attribute).downcase.scan(Regexp.new "\\[\\/#{tag}\\]").length difference = - if > send(attribute) << "[/#{tag}]" end end end end |