Sha256: 15bc4ff1d4c49f318d0e2c73111e8d7bc1eda86e2ca00d456cb0dadb09b52f5b
Contents?: true
Size: 1.47 KB
Versions: 145
Compression:
Stored size: 1.47 KB
Contents
module RubyApp module Mixins module TemplateMixin def get_template_name name = self.to_s.split('::').last name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') name.gsub!(/([a-z\d])([A-Z])/,'\1_\2') name.tr!("-", "_") return name.downcase end def template_path(format, path) (@_template_path ||= {})[format] = File.directory?(path) ? "#{File.join(path, self.get_template_name)}.*.haml" : path end def exclude_parent_template?(format) return ( @_exclude_parent_template_formats ||= [] ).include?(:all) || @_exclude_parent_template_formats.include?(format) end def exclude_parent_template(*formats) @_exclude_parent_template_formats = formats end def get_template(format) return (@_template_path[format] || @_template_path[:all]).gsub(/\*/,format.to_s) end def get_default_template return File.join(File.dirname(__FILE__), %w[template_mixin.haml]) end def get_templates(format) template = self.get_template(format) return (File.exists?(template) ? [template] : []).concat((!self.exclude_parent_template?(format) && self.superclass.respond_to?(:get_templates) ) ? self.superclass.get_templates(format) : []) end def get_cache(format) template = self.get_template(format) return File.join(File.dirname(template), '.cache', File.basename(template)).gsub(/\.haml/, '') end end end end
Version data entries
145 entries across 145 versions & 1 rubygems