gluttonberg/lib/gluttonberg/templates/mixin.rb
def templates
          # Some cheap memoiziation
          @templates ||= begin
            files = Dir.glob(template_glob)
            # Check to see what mode we are in, that'll define how we parse the file names
            if Gluttonberg.localized? or Gluttonberg.translated?
              # Figure out what regex we need
              matcher, mode = if Gluttonberg.localized?
                [/\/#{filename}.(\w+).([a-z-]+).(\w+).(erb|mab|haml)/, :localized]
              elsif Gluttonberg.translated?
                [/\/#{filename}.([a-z-]+).(\w+).(erb|mab|haml)/, :translated]
              end
              files.inject({}) do |memo, file|
                match = file.match(matcher)
                extract_template_details(memo, mode, match) if match
                memo
              end
            else
              # For the non-localized/dialect mode, just collect the various formats
              files.inject([]) do |memo, file|
                match = file.match(/#{filename}.(\w+).(erb|mab|haml)/)
                memo << match[1] if match
                memo
              end
            end
          end
        end
# Returns an array of hashes representing the template files for this 
# a particular model. The return value will vary depending on the current
# mode.
Returns an array of hashes representing the template files for this
a particular model. The return value will vary depending on the current
mode.
Returns an array of hashes representing the template files for this a particular model . The return value will vary depending on the current mode .
def templates
          @templates ||= begin
            files = Dir.glob(template_glob)
            if Gluttonberg.localized? or Gluttonberg.translated?
              matcher, mode = if Gluttonberg.localized?
                [/\/#{filename}.(\w+).([a-z-]+).(\w+).(erb|mab|haml)/, :localized]
              elsif Gluttonberg.translated?
                [/\/#{filename}.([a-z-]+).(\w+).(erb|mab|haml)/, :translated]
              end
              files.inject({}) do |memo, file|
                match = file.match(matcher)
                extract_template_details(memo, mode, match) if match
                memo
              end
            else
              files.inject([]) do |memo, file|
                match = file.match(/#{filename}.(\w+).(erb|mab|haml)/)
                memo << match[1] if match
                memo
              end
            end
          end
        end
def templates @templates ||= begin files = Dir . glob ( template_glob ) if Gluttonberg . localized? or Gluttonberg . translated? matcher , mode = if Gluttonberg . localized? [ / \/ #{ filename } .( \w +).([a-z-]+).( \w +).(erb|mab|haml) / , :localized ] elsif Gluttonberg . translated? [ / \/ #{ filename } .([a-z-]+).( \w +).(erb|mab|haml) / , :translated ] end files . inject ( { } ) do | memo , file | match = file . match ( matcher ) extract_template_details ( memo , mode , match ) if match memo end else files . inject ( [ ] ) do | memo , file | match = file . match ( / #{ filename } .( \w +).(erb|mab|haml) / ) memo << match [ 1 ] if match memo end end end end
Returns an array of hashes representing the template files for this
a particular model.
Returns an array of hashes representing the template files for this a particular model .
# Some cheap memoiziation # Check to see what mode we are in, that'll define how we parse the file names # Figure out what regex we need # For the non-localized/dialect mode, just collect the various formats