Sha256: c6d64931ab7255bb3becd59d5c9a64cacdcefb5075d3d769355aad51a048c1e6
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module Merb module Template module Erubis ::Merb::Controller.register_engine self, %w[ herb jerb erb rhtml ] 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
merb-0.3.1 | lib/merb/template/erubis.rb |
merb-0.3.3 | lib/merb/template/erubis.rb |
merb-0.3.0 | lib/merb/template/erubis.rb |
merb-0.3.4 | lib/merb/template/erubis.rb |