Module: TotoBongo::Template
- Included in:
- Archives, Article, Site::Context
- Defined in:
- lib/toto-bongo.rb
Overview
Handles all templating options Is responsible for:
-
Calling the Haml engine on pages to render them to html
-
Calling the markdown engine on markdown text to render them to html
-
Registering All the classes at initialization
Class Method Summary collapse
-
.included(obj) ⇒ Object
define the following methods during initialization TotoBongo::Site::Context TotoBongo::Repo TotoBongo::Archives TotoBongo::Article.
Instance Method Summary collapse
-
#markdown(text) ⇒ Object
Converst a markdown text into html.
-
#method_missing(m, *args, &blk) ⇒ Object
Intercept any method missing.
-
#to_html(page, config, &blk) ⇒ Object
This will call Haml render Call the config block to make convert the page to html.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Class Method Details
.included(obj) ⇒ Object
define the following methods during initialization TotoBongo::Site::Context TotoBongo::Repo TotoBongo::Archives TotoBongo::Article
104 105 106 107 108 109 |
# File 'lib/toto-bongo.rb', line 104 def self.included obj TotoBongo::logger.debug("Called Template::include: obj = #{obj}") obj.class_eval do define_method(obj.to_s.split('::').last.downcase) { self } end end |
Instance Method Details
#markdown(text) ⇒ Object
Converst a markdown text into html
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/toto-bongo.rb', line 78 def markdown text TotoBongo::logger.debug("Called Template::Markdown") if ( = @config[:markdown]) Markdown.new(text.to_s.strip, *(.eql?(true) ? [] : )).to_html else text.strip end Markdown.new(text.to_s.strip).to_html end |
#to_html(page, config, &blk) ⇒ Object
This will call Haml render Call the config block to make convert the page to html
69 70 71 72 73 |
# File 'lib/toto-bongo.rb', line 69 def to_html page, config, &blk TotoBongo::logger.debug("Called Template::to_html") path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages]) result = config[:to_html].call(path, page, binding) end |