2 problems
- It is looking for ./partial.html and not partial.mustache
- Using the method chain in config.ru you should see "klass is Partial". It seems like it should be PartialDemo::Views::Partial
$:.unshift '../../Ruby/mustache/lib' | |
require 'sinatra/base' | |
require 'mustache/sinatra' | |
require 'partial_demo' | |
use Rack::Lint | |
use Rack::ShowExceptions | |
Mustache::Template.class_eval do | |
alias_method :_cmp_partial, :compile_partial unless method_defined?(:_cmp_partial) | |
def compile_partial(name) | |
puts "--------------------------------------------" | |
puts "klass is #{Mustache.classify(name)}" | |
puts "--------------------------------------------\n\n" | |
_cmp_partial(name) | |
end | |
end | |
run PartialDemo.new |
{{ name }} | |
{{<partial}} |
class PartialDemo | |
module Views | |
class Index < Mustache | |
def name() "Erik" end | |
end | |
end | |
end |
Batteries not {{ included }} |
class PartialDemo | |
module Views | |
class Partial < Mustache | |
def included() "included" end | |
end | |
end | |
end |
class PartialDemo < Sinatra::Base | |
register Mustache::Sinatra | |
set :views, './' | |
set :mustaches, './' | |
get '/' do | |
mustache :index | |
end | |
end |