Class: Marko::Renderers::Content
- Defined in:
- lib/marko/renderers/content.rb
Overview
Content renderer
Constant Summary
Constants inherited from Renderer
Instance Method Summary collapse
-
#initialize ⇒ Content
constructor
A new instance of Content.
- #render(topic) ⇒ Object
Constructor Details
#initialize ⇒ Content
10 11 12 13 14 |
# File 'lib/marko/renderers/content.rb', line 10 def initialize @link = Link.new @list = NestedList.new @tree = NestedTree.new end |
Instance Method Details
#render(topic) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/marko/renderers/content.rb', line 17 def render(topic) String.new(topic.content).tap do |processed| # links substitution topic.links.uniq.each do |link| ref = topic.root.find_by_id(link) || link processed.gsub!("[[#{link}]]", @link.render(ref)) end processed.gsub!(/@@list/, @list.render(topic)) \ if processed =~ /@@list/ processed.gsub!(/@@tree/, @tree.render(topic)) \ if processed =~ /@@tree/ processed.gsub!(/@@skip.*$/m, '') \ if processed =~ /@@skip/ end end |