Sha256: fbbb8f0494d94aa049508ba79973412fa29834182f7ffd56fe948a2a1665931e
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Valise module Strategies class Serialization class Tilt < Serialization register :tilt def self.template_cache @template_cache ||= ::Tilt::Cache.new end def initialize(options) options ||= {} @template_options = options[:template_options] || {} @template_cache = options[:template_cache] || self.class.template_cache end def dump(item) super.data end def load(item) @template_cache.fetch(item.full_path, @template_options) do ::Tilt.new(item.full_path, @template_options) do |tmpl| super end end end end end end class Set def templates(rel_path=nil) rel_path ||= "templates" new_set = self.sub_set(rel_path) new_set = new_set.exts(*([""] + Tilt.mappings.map{|mapping, _| "." + mapping})) ::Tilt.mappings.each do |mapping, _| options = nil if block_given? options = yield(mapping) end new_set.add_serialization_handler("**.#{mapping}", :tilt, options) end new_set end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valise-1.0.0 | lib/valise/adapters/tilt.rb |