Module: BBCoder::Tag::ClassMethods
- Included in:
- BBCoder::Tag
- Defined in:
- lib/bbcoder/tag.rb
Instance Method Summary collapse
-
#handle(tag, depth, meta, content = nil, force_end = false) ⇒ Object
need #handle so we don’t get into a reform loop from to_html checking content validity.
- #reform(tag, meta, content = nil, singularity = false, force_end = false) ⇒ Object
- #reform_end(tag) ⇒ Object
- #reform_open(tag, meta) ⇒ Object
- #to_html(tag, depth, meta, content, singularity = false) ⇒ Object
Instance Method Details
#handle(tag, depth, meta, content = nil, force_end = false) ⇒ Object
need #handle so we don’t get into a reform loop from to_html checking content validity
89 90 91 92 93 94 95 96 |
# File 'lib/bbcoder/tag.rb', line 89 def handle(tag, depth, , content = nil, force_end = false) if BBCoder.configuration[tag] && BBCoder.configuration[tag].singular? to_html(tag, depth, , content, true) else # reform doesn't really care about depth, so we don't pass it in. reform(tag, , content, force_end) end end |
#reform(tag, meta, content = nil, singularity = false, force_end = false) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/bbcoder/tag.rb', line 98 def reform(tag, , content = nil, singularity = false, force_end = false) if (content.nil? && !force_end) || singularity %(#{reform_open(tag, )}) else %(#{reform_open(tag, )}#{content}#{reform_end(tag)}) end end |
#reform_end(tag) ⇒ Object
114 115 116 |
# File 'lib/bbcoder/tag.rb', line 114 def reform_end(tag) "[/#{tag}]" end |
#reform_open(tag, meta) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/bbcoder/tag.rb', line 106 def reform_open(tag, ) if .nil? || .empty? "[#{tag}]" else "[#{tag}=#{}]" end end |
#to_html(tag, depth, meta, content, singularity = false) ⇒ Object
83 84 85 |
# File 'lib/bbcoder/tag.rb', line 83 def to_html(tag, depth, , content, singularity = false) BBCoder.configuration[tag].to_html(depth, , content, singularity) end |