Permalink
Browse files

remove mustache template

The MustacheTemplate implementation hasn't been right for some time
and conflicts with the mustache/sinatra.rb extension library
included with Mustache. Removing for 1.0. This template engine may
be put back in the future if we can find a model that makes sense.
  • Loading branch information...
1 parent daf7f67 commit 7a7912099035e921844e572a19fa90ff20fae9ba @rtomayko committed Jun 15, 2010
Showing with 0 additions and 182 deletions.
  1. +0 −1 README.md
  2. +0 −48 TEMPLATES.md
  3. +0 −49 lib/tilt.rb
  4. +0 −14 test/tilt_mustache_views/external.rb
  5. +0 −70 test/tilt_mustachetemplate_test.rb
View
@@ -30,7 +30,6 @@ Support for these template engines is included with the package:
Less CSS .less less
Builder .builder builder
Liquid .liquid liquid
- Mustache .mustache mustache
RDiscount .markdown rdiscount
RedCloth .textile redcloth
RDoc .rdoc rdoc
View
@@ -9,7 +9,6 @@ documentation on each supported template engine is provided below.
* [Erubis](#erubis) - `Tilt::ErubisTemplate`
* [Haml](#haml) - `Tilt::HamlTemplate`
* [Liquid](#liquid) - `Tilt::LiquidTemplate`
- * [Mustache](#mustache) - `Tilt::MustachTemplate`
Tilt includes support for CSS processors like [lesscss](http://lesscss.org)
and [sass](http://sass-lang.com/), in addition, it also supports simple
@@ -304,53 +303,6 @@ time when using this template engine within a threaded environment.
* [Liquid Docs](http://liquid.rubyforge.org/)
* GitHub: [tobi/liquid](http://github.com/tobi/liquid/)
-<a name='mustache'></a>
-Mustache (`mustache`)
----------------------
-
-Mustache is a framework-agnostic way to render logic-free views.
-
-__NOTE:__ It's suggested that your program `require 'mustache'` at load time
-when using this template engine in a threaded environment.
-
-### Options
-
-#### `:path => Dir.pwd`
-
-The base path where mustache templates (`.html` files) are located. Defaults to
-the current working directory.
-
-#### `:template_extension => 'html'`
-
-The file extension used on mustache templates. Default is `'html'`.
-
-#### `:namespace => Object`
-
-The class or module where View classes are located. If you have
-`Hurl::App::Views`, namespace should be `Hurl:App`. This defaults to `Object`,
-causing `::Views` to be searched for classes.
-
-#### `:mustaches => nil` or `:view_path => nil`
-
-Where mustache views (`.rb` files) are located, or `nil` to disable auto-requiring
-of views based on template names. By default, the view file is assumed to be in
-the same directory as the template file.
-
-All other options are assumed to be attribute writer's on the Mustache
-class and are set when a template is compiled. They are:
-
-#### `:view => nil`
-
-The Mustache subclass that should be used a the view. When this option is
-specified, the template file will be determined from the view class, and the
-`:namespace` and `:mustaches` options are irrelevant.
-
-### See also
-
- * [Mustache Docs](http://defunkt.github.com/mustache/)
- * GitHub: [defunkt/mustache](http://github.com/defunkt/mustache)
-
-
<a name='markdown'></a>
Markdown (`markdown`, `md`, `mkd`)
----------------------------------
View
@@ -671,55 +671,6 @@ def evaluate(scope, locals, &block)
register 'textile', RedClothTemplate
- # Mustache is written and maintained by Chris Wanstrath. See:
- # http://github.com/defunkt/mustache
- #
- # When a scope argument is provided to MustacheTemplate#render, the
- # instance variables are copied from the scope object to the Mustache
- # view.
- class MustacheTemplate < Template
- attr_reader :engine
-
- def initialize_engine
- return if defined? ::Mustache
- require_template_library 'mustache'
- end
-
- def prepare
- Mustache.view_namespace = options[:namespace]
- Mustache.view_path = options[:view_path] || options[:mustaches]
- @engine = options[:view] || Mustache.view_class(name)
- options.each do |key, value|
- next if %w[view view_path namespace mustaches].include?(key.to_s)
- @engine.send("#{key}=", value) if @engine.respond_to? "#{key}="
- end
- end
-
- def evaluate(scope=nil, locals={}, &block)
- instance = @engine.new
-
- # copy instance variables from scope to the view
- scope.instance_variables.each do |name|
- instance.instance_variable_set(name, scope.instance_variable_get(name))
- end
-
- # locals get added to the view's context
- locals.each do |local, value|
- instance[local] = value
- end
-
- # if we're passed a block it's a subview. Sticking it in yield
- # lets us use {{yield}} in layout.html to render the actual page.
- instance[:yield] = block.call if block
-
- instance.template = data unless instance.compiled?
-
- instance.to_html
- end
- end
- register 'mustache', MustacheTemplate
-
-
# RDoc template. See:
# http://rdoc.rubyforge.org/
#
@@ -1,14 +0,0 @@
-begin
- require 'mustache'
-
- module Views
- class External < Mustache
- def hello
- "Stached"
- end
- end
- end
-
-rescue LoadError => boom
- # silently fail, disabled message already displayed
-end
@@ -1,70 +0,0 @@
-require 'contest'
-require 'tilt'
-
-begin
- require 'mustache'
- raise LoadError, "mustache version must be > 0.2.2" if !Mustache.respond_to?(:compiled?)
-
- module Views
- class Foo < Mustache
- attr_reader :foo
- end
- end
-
- class MustacheTemplateTest < Test::Unit::TestCase
- test "registered for '.mustache' files" do
- assert_equal Tilt::MustacheTemplate, Tilt['test.mustache']
- end
-
- test "preparing and evaluating templates on #render" do
- template = Tilt::MustacheTemplate.new { |t| "Hello World!" }
- assert_equal "Hello World!", template.render
- end
-
- test "passing locals" do
- template = Tilt::MustacheTemplate.new { "<p>Hey {{name}}!</p>" }
- assert_equal "<p>Hey Joe!</p>", template.render(nil, :name => 'Joe')
- end
-
- test "passing a block for yield" do
- template = Tilt::MustacheTemplate.new { "<p>Hey {{yield}}!</p>" }
- assert_equal "<p>Hey Joe!</p>", template.render { 'Joe' }
- end
-
- test "locating views defined at the top-level" do
- template = Tilt::MustacheTemplate.new('foo.mustache') { "<p>Hey {{foo}}!</p>" }
- assert_equal Views::Foo, template.engine
- end
-
- module Bar
- module Views
- class Bizzle < Mustache
- end
- end
- end
-
- test "locating views defined in a custom namespace" do
- template = Tilt::MustacheTemplate.new('bizzle.mustache', :namespace => Bar) { "<p>Hello World!</p>" }
- assert_equal Bar::Views::Bizzle, template.engine
- assert_equal "<p>Hello World!</p>", template.render
- end
-
- test "locating views in files" do
- view_path = File.expand_path('../tilt_mustache_views', __FILE__)
- template = Tilt::MustacheTemplate.new('external.mustache', :view_path => view_path) { "<p>{{hello}}!</p>" }
- assert defined?(Views::External), "external.rb should have been required"
- assert_equal Views::External, template.engine
- assert_equal "<p>Stached!</p>", template.render
- end
-
- test "copying instance variables from scope object" do
- template = Tilt::MustacheTemplate.new('foo.mustache') { "<p>Hey {{foo}}!</p>" }
- scope = Object.new
- scope.instance_variable_set(:@foo, 'Jane!')
- assert_equal "<p>Hey Jane!!</p>", template.render(scope)
- end
- end
-
-rescue LoadError => boom
- warn "Tilt::MustacheTemplate (disabled)\n"
-end

0 comments on commit 7a79120

Please sign in to comment.