Sha256: cc26125a6f28c00ee932353164ca61158dc7ed2f8d8aa0727715b0cab52c04f0
Contents?: true
Size: 1019 Bytes
Versions: 16
Compression:
Stored size: 1019 Bytes
Contents
module RubySlippers module Engine class Context include Template attr_reader :env def initialize ctx = {}, config = {}, path = "/", env = {} @config, @context, @path, @env = config, ctx, path, env @articles = Site.articles(@config[:ext]).reverse.map do |a| Article.new(a, @config) end ctx.each do |k, v| meta_def(k) { ctx.instance_of?(Hash) ? v : ctx.send(k) } end end def title @config[:title] end def render page, type content = to_html page, @config type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page) end def to_xml page xml = Builder::XmlMarkup.new(:indent => 2) instance_eval File.read("#{Paths[:templates]}/#{page}.builder") end alias :to_atom to_xml def method_missing m, *args, &blk @context.respond_to?(m) ? @context.send(m, *args, &blk) : super end end end end
Version data entries
16 entries across 16 versions & 2 rubygems