Class: Monograph::BookTemplateContext
- Inherits:
-
TemplateContext
- Object
- TemplateContext
- Monograph::BookTemplateContext
- Defined in:
- lib/monograph/book_template_context.rb
Overview
The BookTemplateContext is used whenever a non-chapter page (cover, contents) is to be rendered within the template.
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
Instance Method Summary collapse
- #author ⇒ Object
- #content ⇒ Object
-
#initialize(book, template) ⇒ BookTemplateContext
constructor
A new instance of BookTemplateContext.
- #next_page ⇒ Object
- #page_title ⇒ Object
- #permalink ⇒ Object
- #previous_page ⇒ Object
- #title ⇒ Object
Methods inherited from TemplateContext
Constructor Details
#initialize(book, template) ⇒ BookTemplateContext
Returns a new instance of BookTemplateContext.
8 9 10 11 |
# File 'lib/monograph/book_template_context.rb', line 8 def initialize(book, template) @book = book @template = template end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
6 7 8 |
# File 'lib/monograph/book_template_context.rb', line 6 def book @book end |
Instance Method Details
#author ⇒ Object
28 29 30 |
# File 'lib/monograph/book_template_context.rb', line 28 def @book.config['author'] end |
#content ⇒ Object
13 14 15 |
# File 'lib/monograph/book_template_context.rb', line 13 def content @content ||= @book.template_file(@template) end |
#next_page ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/monograph/book_template_context.rb', line 36 def next_page case @template when 'index.html' self.class.new(@book, 'contents.html') when 'contents.html' @book.chapters.first end end |
#page_title ⇒ Object
17 18 19 |
# File 'lib/monograph/book_template_context.rb', line 17 def page_title title end |
#permalink ⇒ Object
32 33 34 |
# File 'lib/monograph/book_template_context.rb', line 32 def permalink @template.gsub(/\.html\z/, '') end |
#previous_page ⇒ Object
45 46 47 48 49 50 |
# File 'lib/monograph/book_template_context.rb', line 45 def previous_page case @template when 'contents.html' self.class.new(@book, 'index.html') end end |
#title ⇒ Object
21 22 23 24 25 26 |
# File 'lib/monograph/book_template_context.rb', line 21 def title case @template when 'index.html' then @book.title when 'contents.html' then 'Contents' end end |