Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify Mustache template. Tests all pass but requires Mustache 0.4.0

  • Loading branch information...
commit 39d137a23e19163dcbdb2783b303e4f85080260b 1 parent 953ca51
@defunkt defunkt authored
Showing with 3 additions and 23 deletions.
  1. +3 −23 lib/tilt.rb
View
26 lib/tilt.rb
@@ -354,23 +354,16 @@ 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
+ Mustache.view_class(name)
end
# set options on the view class
@@ -402,19 +395,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
Please sign in to comment.
Something went wrong with that request. Please try again.