Class: MarkdownSite::JournalTemplate
- Defined in:
- lib/markdown_site/templates/journal_template.rb
Instance Attribute Summary
Attributes inherited from Template
Instance Method Summary collapse
- #generate(site_journals) ⇒ Object
-
#initialize(site) ⇒ JournalTemplate
constructor
A new instance of JournalTemplate.
Methods inherited from Template
Constructor Details
#initialize(site) ⇒ JournalTemplate
Returns a new instance of JournalTemplate.
3 4 5 |
# File 'lib/markdown_site/templates/journal_template.rb', line 3 def initialize(site) super(site) end |
Instance Method Details
#generate(site_journals) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/markdown_site/templates/journal_template.rb', line 6 def generate(site_journals) journal_list = [] site_journals.reverse.each do |journal| journal_template = Liquid::Template.parse(File.read(@site_config.journal_template)) journal_html = journal_template.render('title'=>journal.item_name, 'content'=>journal.html) journal_list << journal_html end template = Liquid::Template.parse(File.read(@site_config.journals_template)) page_count = (journal_list.size / 20) + 1 1.upto(page_count) do |page_number| pagination, f = get_pagination("index", page_count, page_number) page_start = (page_number-1)*20 if page_number == page_count f.puts(template.render('config'=>{'title'=>@site_config.title}, 'journal_list'=>journal_list[page_start..-1], 'pagination'=>pagination)) else f.puts(template.render('config'=>{'title'=>@site_config.title}, 'journal_list'=>journal_list[page_start..page_start+20], 'pagination'=>pagination)) end f.close end end |