Skip to content

Instantly share code, notes, and snippets.

@judofyr
Created April 26, 2010 09:31
Show Gist options
  • Save judofyr/379142 to your computer and use it in GitHub Desktop.
Save judofyr/379142 to your computer and use it in GitHub Desktop.
T = {}
L = :layout
# Finds a template, returning either:
#
# false # => Could not find template
# true # => Found template in Views
# instance of Tilt # => Found template in a file
def lookup(n)
T.fetch(n.to_sym) do |k|
T[k] = Views.method_defined?(k) ||
(f = Dir[[O[:views] || "views", "#{n}.*"]*'/'][0]) &&
Tilt.new(f, O[f[/\.(\w+)$/, 1].to_sym] || {})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment