Sha256: 7b4ca0fba31f73bf082cec8a5e0e119dc4c75e16c8b8de14a74cb456208a0cd3
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
module Merb module Template module Erubis ::Merb::Controller.register_engine self, %w[ herb jerb erb ] class << self @@erbs = {} @@mtimes = {} def exempt_from_layout? false end def transform(options = {}) opts, file, view_context = options.values_at(:opts, :file, :view_context) eruby = new_eruby_obj(file) view_context.class.send(:include, ::Merb::ErubisCaptureMixin) eruby.evaluate(view_context) end def new_eruby_obj(path) if @@erbs[path] && !cache_template?(path) return @@erbs[path] else begin returning ::Erubis::MEruby.new(IO.read(path)) do |eruby| eruby.init_evaluator :filename => path if cache_template?(path) @@erbs[path], @@mtimes[path] = eruby, Time.now end end rescue Errno::ENOENT raise "No template found at path: #{path}" end end end def cache_template?(path) return false unless ::Merb::Server.config[:cache_templates] return true unless @@erbs[path] @@mtimes[path] < File.mtime(path) || (File.symlink?(path) && (@@mtimes[path] < File.lstat(path).mtime)) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
merb-0.2.0 | lib/merb/template/erubis.rb |