Sha256: 26a090d5667c088d5cc0e3c1ad9a509335bd368b6405d5fb9f2f642ecef0cb49

Contents?: true

Size: 646 Bytes

Versions: 4

Compression:

Stored size: 646 Bytes

Contents

module Allegro

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

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

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

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


end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
allegro-0.0.0pre3 lib/allegro/template.rb
allegro-0.0.0pre2 lib/allegro/template.rb
allegro-0.0.0pre1 lib/allegro/template.rb
allegro-0.0.0pre lib/allegro/template.rb