Sha256: a8b17fefdfb64f27b259fb37ece0c9fb68ccdcf8de41c160b89f6435a22325b6
Contents?: true
Size: 750 Bytes
Versions: 9
Compression:
Stored size: 750 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" path = Templates.loader.context.to_s/name id = [path, options.to_a].flatten.join('-') template = Templates.with_caching(id) do Slim::Template.new(path, options) { Templates.loader.load(name) } end template.render(self, locals, &block).html_safe end end end
Version data entries
9 entries across 9 versions & 1 rubygems