Sha256: cd186dd5876b214e70114a09a13a4bbd625694ead723a41329bcc5b83d354366
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
require 'plezi/render/has_cache' unless defined? ::Plezi::Base::HasStore require 'erb' module Plezi module Base module RenderERB extend ::Plezi::Base::HasStore module_function def call(filename, context, &block) return unless defined? ::ERB return unless File.exist?(filename) engine = load_engine(filename) engine.result(context, &block) end if ENV['RACK_ENV'.freeze] == 'production'.freeze def load_engine(filename) engine = self[filename] return engine if engine self[filename] = ::ERB.new(::Plezi.try_utf8!(IO.binread(filename))) end else def load_engine(filename) engine, tm = self[filename] return engine if engine && (tm == File.mtime(filename)) self[filename] = [(engine = ::ERB.new(::Plezi.try_utf8!(IO.binread(filename)))), File.mtime(filename)] engine end end end end end ::Plezi::Renderer.register :erb, ::Plezi::Base::RenderERB
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
plezi-0.14.4 | lib/plezi/render/erb.rb |
plezi-0.14.3 | lib/plezi/render/erb.rb |
plezi-0.14.2 | lib/plezi/render/erb.rb |
plezi-0.14.1 | lib/plezi/render/erb.rb |
plezi-0.14.0 | lib/plezi/render/erb.rb |