Skip to content

Commit

Permalink
remove mustache template
Browse files Browse the repository at this point in the history
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
rtomayko committed Jun 15, 2010
1 parent daf7f67 commit 7a79120
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 182 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
48 changes: 0 additions & 48 deletions TEMPLATES.md
Expand Up @@ -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
Expand Down Expand Up @@ -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`)
----------------------------------
Expand Down
49 changes: 0 additions & 49 deletions lib/tilt.rb
Expand Up @@ -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/
#
Expand Down
14 changes: 0 additions & 14 deletions test/tilt_mustache_views/external.rb

This file was deleted.

70 changes: 0 additions & 70 deletions test/tilt_mustachetemplate_test.rb

This file was deleted.

0 comments on commit 7a79120

Please sign in to comment.