Module: RubySlippers::Engine::Template

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



17
18
19
# File 'lib/ruby_slippers/template.rb', line 17

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

Class Method Details

.included(obj) ⇒ Object



21
22
23
24
25
# File 'lib/ruby_slippers/template.rb', line 21

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



9
10
11
12
13
14
15
# File 'lib/ruby_slippers/template.rb', line 9

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



4
5
6
7
# File 'lib/ruby_slippers/template.rb', line 4

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