开发者

Mustache & Sinatra - is it possible to omit the view.rb file?

I'm using the Mustache templating library with Sinatra and the standard way seems to be to create, say, index.mustache under /templates and an associated index.rb that subclasses Mustache in /views.

For things like the Ab开发者_如何学编程out page, where no special logic happens at all, how is it possible to use only a .mustache template and still do the following in Sinatra:

get "/" do
  mustache :about
end

When I simply don't provide the index.rb file, Mustache throws an error about not being able to find it.


I think the solution is very simple. If you don't have a view model (like index.rb) you just use another template system like erb

erb :about

or if the file is static just put it here

./public/about.html

I doesn't make sense to hava .mustache template without a view model.


That view requirement is annoying. Jason Campbell comes to the rescue with https://github.com/jxson/sinatra-mustache

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜