Skip to content
This repository
Browse code

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...
commit 7a7912099035e921844e572a19fa90ff20fae9ba 1 parent daf7f67
Ryan Tomayko authored June 15, 2010
1  README.md
Source Rendered
@@ -30,7 +30,6 @@ Support for these template engines is included with the package:
30 30
     Less CSS                   .less             less
31 31
     Builder                    .builder          builder
32 32
     Liquid                     .liquid           liquid
33  
-    Mustache                   .mustache         mustache
34 33
     RDiscount                  .markdown         rdiscount
35 34
     RedCloth                   .textile          redcloth
36 35
     RDoc                       .rdoc             rdoc
48  TEMPLATES.md
Source Rendered
@@ -9,7 +9,6 @@ documentation on each supported template engine is provided below.
9 9
  * [Erubis](#erubis) - `Tilt::ErubisTemplate`
10 10
  * [Haml](#haml) - `Tilt::HamlTemplate`
11 11
  * [Liquid](#liquid) - `Tilt::LiquidTemplate`
12  
- * [Mustache](#mustache) - `Tilt::MustachTemplate`
13 12
 
14 13
 Tilt includes support for CSS processors like [lesscss](http://lesscss.org)
15 14
 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.
304 303
   * [Liquid Docs](http://liquid.rubyforge.org/)
305 304
   * GitHub: [tobi/liquid](http://github.com/tobi/liquid/)
306 305
 
307  
-<a name='mustache'></a>
308  
-Mustache (`mustache`)
309  
----------------------
310  
-
311  
-Mustache is a framework-agnostic way to render logic-free views.
312  
-
313  
-__NOTE:__ It's suggested that your program `require 'mustache'` at load time
314  
-when using this template engine in a threaded environment.
315  
-
316  
-### Options
317  
-
318  
-#### `:path => Dir.pwd`
319  
-
320  
-The base path where mustache templates (`.html` files) are located.  Defaults to
321  
-the current working directory.
322  
-
323  
-#### `:template_extension => 'html'`
324  
-
325  
-The file extension used on mustache templates. Default is `'html'`.
326  
-
327  
-#### `:namespace => Object`
328  
-
329  
-The class or module where View classes are located. If you have
330  
-`Hurl::App::Views`, namespace should be `Hurl:App`. This defaults to `Object`,
331  
-causing `::Views` to be searched for classes.
332  
-
333  
-#### `:mustaches => nil` or `:view_path => nil`
334  
-
335  
-Where mustache views (`.rb` files) are located, or `nil` to disable auto-requiring
336  
-of views based on template names. By default, the view file is assumed to be in
337  
-the same directory as the template file.
338  
-
339  
-All other options are assumed to be attribute writer's on the Mustache
340  
-class and are set when a template is compiled. They are:
341  
-
342  
-#### `:view => nil`
343  
-
344  
-The Mustache subclass that should be used a the view. When this option is
345  
-specified, the template file will be determined from the view class, and the
346  
-`:namespace` and `:mustaches` options are irrelevant.
347  
-
348  
-### See also
349  
-
350  
-  * [Mustache Docs](http://defunkt.github.com/mustache/)
351  
-  * GitHub: [defunkt/mustache](http://github.com/defunkt/mustache)
352  
-
353  
-
354 306
 <a name='markdown'></a>
355 307
 Markdown (`markdown`, `md`, `mkd`)
356 308
 ----------------------------------
49  lib/tilt.rb
@@ -671,55 +671,6 @@ def evaluate(scope, locals, &block)
671 671
   register 'textile', RedClothTemplate
672 672
 
673 673
 
674  
-  # Mustache is written and maintained by Chris Wanstrath. See:
675  
-  # http://github.com/defunkt/mustache
676  
-  #
677  
-  # When a scope argument is provided to MustacheTemplate#render, the
678  
-  # instance variables are copied from the scope object to the Mustache
679  
-  # view.
680  
-  class MustacheTemplate < Template
681  
-    attr_reader :engine
682  
-
683  
-    def initialize_engine
684  
-      return if defined? ::Mustache
685  
-      require_template_library 'mustache'
686  
-    end
687  
-
688  
-    def prepare
689  
-      Mustache.view_namespace = options[:namespace]
690  
-      Mustache.view_path = options[:view_path] || options[:mustaches]
691  
-      @engine = options[:view] || Mustache.view_class(name)
692  
-      options.each do |key, value|
693  
-        next if %w[view view_path namespace mustaches].include?(key.to_s)
694  
-        @engine.send("#{key}=", value) if @engine.respond_to? "#{key}="
695  
-      end
696  
-    end
697  
-
698  
-    def evaluate(scope=nil, locals={}, &block)
699  
-      instance = @engine.new
700  
-
701  
-      # copy instance variables from scope to the view
702  
-      scope.instance_variables.each do |name|
703  
-        instance.instance_variable_set(name, scope.instance_variable_get(name))
704  
-      end
705  
-
706  
-      # locals get added to the view's context
707  
-      locals.each do |local, value|
708  
-        instance[local] = value
709  
-      end
710  
-
711  
-      # if we're passed a block it's a subview. Sticking it in yield
712  
-      # lets us use {{yield}} in layout.html to render the actual page.
713  
-      instance[:yield] = block.call if block
714  
-
715  
-      instance.template = data unless instance.compiled?
716  
-
717  
-      instance.to_html
718  
-    end
719  
-  end
720  
-  register 'mustache', MustacheTemplate
721  
-
722  
-
723 674
   # RDoc template. See:
724 675
   # http://rdoc.rubyforge.org/
725 676
   #
14  test/tilt_mustache_views/external.rb
... ...
@@ -1,14 +0,0 @@
1  
-begin
2  
-  require 'mustache'
3  
-
4  
-  module Views
5  
-    class External < Mustache
6  
-      def hello
7  
-        "Stached"
8  
-      end
9  
-    end
10  
-  end
11  
-
12  
-rescue LoadError => boom
13  
-  # silently fail, disabled message already displayed
14  
-end
70  test/tilt_mustachetemplate_test.rb
... ...
@@ -1,70 +0,0 @@
1  
-require 'contest'
2  
-require 'tilt'
3  
-
4  
-begin
5  
-  require 'mustache'
6  
-  raise LoadError, "mustache version must be > 0.2.2" if !Mustache.respond_to?(:compiled?)
7  
-
8  
-  module Views
9  
-    class Foo < Mustache
10  
-      attr_reader :foo
11  
-    end
12  
-  end
13  
-
14  
-  class MustacheTemplateTest < Test::Unit::TestCase
15  
-    test "registered for '.mustache' files" do
16  
-      assert_equal Tilt::MustacheTemplate, Tilt['test.mustache']
17  
-    end
18  
-
19  
-    test "preparing and evaluating templates on #render" do
20  
-      template = Tilt::MustacheTemplate.new { |t| "Hello World!" }
21  
-      assert_equal "Hello World!", template.render
22  
-    end
23  
-
24  
-    test "passing locals" do
25  
-      template = Tilt::MustacheTemplate.new { "<p>Hey {{name}}!</p>" }
26  
-      assert_equal "<p>Hey Joe!</p>", template.render(nil, :name => 'Joe')
27  
-    end
28  
-
29  
-    test "passing a block for yield" do
30  
-      template = Tilt::MustacheTemplate.new { "<p>Hey {{yield}}!</p>" }
31  
-      assert_equal "<p>Hey Joe!</p>", template.render { 'Joe' }
32  
-    end
33  
-
34  
-    test "locating views defined at the top-level" do
35  
-      template = Tilt::MustacheTemplate.new('foo.mustache') { "<p>Hey {{foo}}!</p>" }
36  
-      assert_equal Views::Foo, template.engine
37  
-    end
38  
-
39  
-    module Bar
40  
-      module Views
41  
-        class Bizzle < Mustache
42  
-        end
43  
-      end
44  
-    end
45  
-
46  
-    test "locating views defined in a custom namespace" do
47  
-      template = Tilt::MustacheTemplate.new('bizzle.mustache', :namespace => Bar) { "<p>Hello World!</p>" }
48  
-      assert_equal Bar::Views::Bizzle, template.engine
49  
-      assert_equal "<p>Hello World!</p>", template.render
50  
-    end
51  
-
52  
-    test "locating views in files" do
53  
-      view_path = File.expand_path('../tilt_mustache_views', __FILE__)
54  
-      template = Tilt::MustacheTemplate.new('external.mustache', :view_path => view_path) { "<p>{{hello}}!</p>" }
55  
-      assert defined?(Views::External), "external.rb should have been required"
56  
-      assert_equal Views::External, template.engine
57  
-      assert_equal "<p>Stached!</p>", template.render
58  
-    end
59  
-
60  
-    test "copying instance variables from scope object" do
61  
-      template = Tilt::MustacheTemplate.new('foo.mustache') { "<p>Hey {{foo}}!</p>" }
62  
-      scope = Object.new
63  
-      scope.instance_variable_set(:@foo, 'Jane!')
64  
-      assert_equal "<p>Hey Jane!!</p>", template.render(scope)
65  
-    end
66  
-  end
67  
-
68  
-rescue LoadError => boom
69  
-  warn "Tilt::MustacheTemplate (disabled)\n"
70  
-end

0 notes on commit 7a79120

Please sign in to comment.
Something went wrong with that request. Please try again.