Class: Baron::PageController
- Inherits:
-
Object
- Object
- Baron::PageController
- Defined in:
- lib/baron/page_controller.rb
Instance Method Summary collapse
-
#initialize(articles_parts, categories, max_articles, params, theme, config) ⇒ PageController
constructor
A new instance of PageController.
- #render(template) ⇒ Object
- #render_html(partial_template, layout_template) ⇒ Object
Constructor Details
#initialize(articles_parts, categories, max_articles, params, theme, config) ⇒ PageController
Returns a new instance of PageController.
4 5 6 7 8 9 |
# File 'lib/baron/page_controller.rb', line 4 def initialize articles_parts, categories, max_articles, params, theme, config @categories, @params, @theme, @config = categories, params, theme, config stop_at = (:all == max_articles) ? articles_parts.count : max_articles @articles = articles_parts.take(stop_at).map { |file_parts| Article.new(file_parts, @config) } @article = @articles.first end |
Instance Method Details
#render(template) ⇒ Object
20 21 22 |
# File 'lib/baron/page_controller.rb', line 20 def render template ERB.new(File.read(template)).result(binding) end |
#render_html(partial_template, layout_template) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/baron/page_controller.rb', line 11 def render_html partial_template, layout_template @content = ERB.new(File.read(partial_template)).result(binding) if @content[0..99].include? '<html' return @content else ERB.new(File.read(layout_template)).result(binding) end end |