Sha256: 5a0f2756c0634c7e752e70f60dcfb893d29b0e74fc02f735ae4524675992662c
Contents?: true
Size: 936 Bytes
Versions: 3
Compression:
Stored size: 936 Bytes
Contents
module Stachio Mustache.raise_on_context_miss = true class Template < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection lookup_by :template_name validates_presence_of :template_name, :content attr_accessor :presents, :rendered def reset self.rendered = nil end def render(options={}) options = options.with_indifferent_access reset if !!(options[:force] or options[:reset]) self.rendered ||= Mustache.render(content, presents) unless presents.nil? end alias_method :assemble, :render alias_method :composite, :render alias_method :compose, :render def present(values=nil, options={}) return render if values.nil? self.presents = values render options.merge(:force => true) end def describe(n=32) (description && description.size > n) ? description[0..n] + ' [...]' : description end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stachio-0.2.1 | app/models/stachio/template.rb |
stachio-0.2.0 | app/models/stachio/template.rb |
stachio-0.1.0 | app/models/stachio/template.rb |