Module: Toto::Template

Included in:
Archives, Article, Repo, Site::Context
Defined in:
lib/toto.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



50
51
52
# File 'lib/toto.rb', line 50

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

Class Method Details

.included(obj) ⇒ Object



54
55
56
57
58
# File 'lib/toto.rb', line 54

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



42
43
44
45
46
47
48
# File 'lib/toto.rb', line 42

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, config, &blk) ⇒ Object



37
38
39
40
# File 'lib/toto.rb', line 37

def to_html page, config, &blk
  path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
  config[:to_html].call(path, page, binding)
end