gluttonberg/lib/gluttonberg/templates/mixin.rb
def template_for(filename, opts = {})
          # A bunch of potential matches in order of preference.
          candidates = if Gluttonberg.localized?
            # Locale and dialect
            # Locale only
            # Default
            [
              "#{filename}.#{opts[:locale].slug}.#{opts[:dialect].code}",
              "#{filename}.#{opts[:locale].slug}",
              "#{filename}"
            ]
          elsif Gluttonberg.translated?
            # Dialect
            # Default
            [
              "#{filename}.#{opts[:dialect].code}",
              "#{filename}"
            ]
          else
            ["#{filename}.*"]
          end
          # Loop through them and return the first match
          for candidate in candidates 
            path = template_dir / candidate + ".*"
            matches = Dir.glob(path)
            return candidate unless matches.empty?
          end
          # This nil has to be here, otherwise the last evaluated object is 
          # returned, in this case the candidates hash.
          nil
        end
# Returns a specific template, or alternately returns a default.
Returns a specific template, or alternately returns a default.
Returns a specific template or alternately returns a default .
def template_for(filename, opts = {})
          candidates = if Gluttonberg.localized?
            [
              "#{filename}.#{opts[:locale].slug}.#{opts[:dialect].code}",
              "#{filename}.#{opts[:locale].slug}",
              "#{filename}"
            ]
          elsif Gluttonberg.translated?
            [
              "#{filename}.#{opts[:dialect].code}",
              "#{filename}"
            ]
          else
            ["#{filename}.*"]
          end
          for candidate in candidates 
            path = template_dir / candidate + ".*"
            matches = Dir.glob(path)
            return candidate unless matches.empty?
          end
          nil
        end
def template_for ( filename , opts = { } ) candidates = if Gluttonberg . localized? [ "#{filename}.#{opts[:locale].slug}.#{opts[:dialect].code}" , "#{filename}.#{opts[:locale].slug}" , "#{filename}" ] elsif Gluttonberg . translated? [ "#{filename}.#{opts[:dialect].code}" , "#{filename}" ] else [ "#{filename}.*" ] end for candidate in candidates path = template_dir / candidate + ".*" matches = Dir . glob ( path ) return candidate unless matches . empty? end nil end
Returns a specific template, or alternately returns a default.
Returns a specific template or alternately returns a default .
# A bunch of potential matches in order of preference. # Locale and dialect # Locale only # Default # Dialect # Default # Loop through them and return the first match # This nil has to be here, otherwise the last evaluated object is  # returned, in this case the candidates hash.
filename
opts