Class: Shortcodes::Parser
- Inherits:
-
Object
- Object
- Shortcodes::Parser
- Defined in:
- lib/shortcodes/parser.rb
Defined Under Namespace
Classes: Shortcode
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(content) ⇒ Parser
constructor
A new instance of Parser.
- #to_html ⇒ Object
Constructor Details
#initialize(content) ⇒ Parser
Returns a new instance of Parser.
14 15 16 |
# File 'lib/shortcodes/parser.rb', line 14 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/shortcodes/parser.rb', line 12 def content @content end |
Instance Method Details
#to_html ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/shortcodes/parser.rb', line 20 def to_html content.gsub(/\[[^\]]+\]/) do |code| shortcode = parse_shortcode(code) get_handler(shortcode).call shortcode end end |