Permalink
Browse files

Merge defunkt/simpler_mustache_loading

  • Loading branch information...
2 parents e9782ef + a19c10f commit 7dd0b015cc0b397d55079ccde5c6ddb9d8d6a419 @rtomayko committed Oct 29, 2009
Showing with 3 additions and 29 deletions.
  1. +3 −29 lib/tilt.rb
View
@@ -354,24 +354,11 @@ class MustacheTemplate < Template
def compile!
require_template_library 'mustache' unless defined?(::Mustache)
- @view_name = Mustache.classify(name.to_s)
- @namespace = options[:namespace] || Object
+ # Set the Mustache view namespace if we can
+ Mustache.view_namespace = options[:namespace]
# Figure out which Mustache class to use.
- @engine =
- if options[:view]
- @view_name = options[:view].name
- options[:view]
- elsif @namespace.const_defined?(:Views) &&
- @namespace::Views.const_defined?(@view_name)
- @namespace::Views.const_get(@view_name)
- elsif load_mustache_view
- engine = @namespace::Views.const_get(@view_name)
- engine.template = data
- engine
- else
- Mustache
- end
+ @engine = options[:view] || Mustache.view_class(name)
# set options on the view class
options.each do |key, value|
@@ -402,19 +389,6 @@ def evaluate(scope=nil, locals={}, &block)
instance.to_html
end
-
- # Require the mustache view lib if it exists.
- def load_mustache_view
- return if name.nil?
- path = "#{options[:mustaches]}/#{name}.rb"
- if options[:mustaches] && File.exist?(path)
- require path.chomp('.rb')
- path
- elsif File.exist?(path = file.sub(/\.[^\/]+$/, '.rb'))
- require path.chomp('.rb')
- path
- end
- end
end
register 'mustache', MustacheTemplate
end

0 comments on commit 7dd0b01

Please sign in to comment.