Module: Toto::Template

Included in:
Archives, Article, Repo, Site::Context
Defined in:
lib/toto-haml.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &blk) ⇒ Object



44
45
46
# File 'lib/toto-haml.rb', line 44

def method_missing m, *args, &blk
  self.keys.include?(m) ? self[m] : super
end

Class Method Details

.included(obj) ⇒ Object



48
49
50
51
52
# File 'lib/toto-haml.rb', line 48

def self.included obj
  obj.class_eval do
    define_method(obj.to_s.split('::').last.downcase) { self }
  end
end

Instance Method Details

#markdown(text) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/toto-haml.rb', line 36

def markdown text
  if (options = @config[:markdown])
    Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html
  else
    text.strip
  end
end

#to_html(page, &blk) ⇒ Object



31
32
33
34
# File 'lib/toto-haml.rb', line 31

def to_html page, &blk
  path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
  return Haml::Engine.new(File.read("#{path}/#{page}.haml")).render(binding)
end