Class: Juli::Visitor::Html::Helper::Contents
- Inherits:
-
AbstractHelper
- Object
- AbstractHelper
- Juli::Visitor::Html::Helper::Contents
- Defined in:
- lib/juli/visitor/html/helper/contents.rb
Overview
Helper-class for ‘contents’ helper
Defined Under Namespace
Classes: ChapterChecker, ContentsDrawer
Instance Method Summary collapse
-
#on_root(in_file, root, visitor = nil) ⇒ Object
called on each parsed document.
-
#run(*args) ⇒ Object
implementation of: contents.
Methods inherited from AbstractHelper
conf_template, #initialize, #set_conf_default
Methods included from Util
#camelize, conf, find_template, in_filename, juli_repo, mkdir, out_filename, str_limit, str_trim, to_wikiname, underscore, usage, visitor, visitor_list
Constructor Details
This class inherits a constructor from Juli::Visitor::Html::Helper::AbstractHelper
Instance Method Details
#on_root(in_file, root, visitor = nil) ⇒ Object
called on each parsed document
51 52 53 |
# File 'lib/juli/visitor/html/helper/contents.rb', line 51 def on_root(in_file, root, visitor = nil) @root = root end |
#run(*args) ⇒ Object
implementation of:
contents
which draws contents(a.k.a. outline) of this document.
This visits document tree by ContentsDrawer visitor and generate HTML contents list.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/juli/visitor/html/helper/contents.rb', line 62 def run(*args) contents_drawer = ContentsDrawer.new chapter_checker = ChapterChecker.new @root.accept(chapter_checker) if chapter_checker.chapter_exists contents_drawer.content_tag(:b, I18n.t('contents')) + contents_drawer.content_tag(:ol) do @root.accept(contents_drawer) end else '' end end |