glog 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/glog/template.rb +12 -8
  2. metadata +2 -2
data/lib/glog/template.rb CHANGED
@@ -12,8 +12,8 @@ module Glog
12
12
  end
13
13
 
14
14
  def initialize(page, locals = nil)
15
- @page = page
16
- @locals = locals
15
+ @page = page
16
+ @locals = locals
17
17
  if page.template
18
18
  @template = File.read(build_template_path(page.template))
19
19
  else
@@ -21,15 +21,17 @@ module Glog
21
21
  end
22
22
  end
23
23
 
24
- def render(path = nil, locals = {})
24
+ def render(path = nil, locals = {}, &block)
25
25
  template = path ? File.read("templates" + File::SEPARATOR + path + '.haml') : @template
26
- render_string(template, locals)
26
+ inner_html = block_given? ? yield : ''
27
+ inner_html = inner_html == 0 ? '' : inner_html
28
+ render_string(template, locals, inner_html)
27
29
  end
28
30
 
29
- private
30
-
31
- def render_string(string, locals = {})
32
- Engine.new(string).render(self, @locals.merge(locals))
31
+ def render_string(string, locals = {}, inner_html = '')
32
+ Engine.new(string).render(self, @locals.merge(locals)) do
33
+ render_string(inner_html)
34
+ end
33
35
  end
34
36
 
35
37
  def find_for(page_path)
@@ -37,6 +39,8 @@ module Glog
37
39
  File.read template_path || 'templates/default.haml'
38
40
  end
39
41
 
42
+ private
43
+
40
44
  def possible_paths_for(page_path)
41
45
  return [] if page_path.nil?
42
46
  segments = page_path.split(File::SEPARATOR)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 8
9
- version: 0.0.8
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Antono Vasiljev