Sha256: 213181fe84680c677a5ee169b814ddc8de224ad7bd417861f6eb87b7eb10ff83
Contents?: true
Size: 702 Bytes
Versions: 7
Compression:
Stored size: 702 Bytes
Contents
module Olelo module Templates class << self attr_reader :cache attr_accessor :loader def enable_caching @cache = {} end def with_caching(id) return cache[id] if cache && cache[id] template = yield cache[id] = template if cache template end end def render(name, options = {}, &block) locals = options.delete(:locals) || {} name = "#{name}.slim" id = [name, options.to_a].flatten.join('-') template = Templates.with_caching(id) do Slim::Template.new(name, options) { Templates.loader.call(name) } end template.render(self, locals, &block).html_safe end end end
Version data entries
7 entries across 7 versions & 1 rubygems