views:

257

answers:

3

The idea would be to replace ERB with templates that are pure XHTML and that the view would be pure code manipulating the template content.

Have this been done already ?

A: 

I'm not sure if this is exactly what you mean, but mustache sounds similar:

http://github.com/defunkt/mustache http://www.rubyinside.com/mustache-for-logicfree-views-in-your-ruby-web-apps-2599.html

psyho
Mustache is in the line of what I'm looking for, however the {{#section}} blachblach {{/section}} seems "not so nice" compared to Wicket style:<div mustache:id="section">blachabach</div>Any chance of having a XHTML based Mustache like template system ? O r having an "alternative notation" available in Mustache ?
rodrigob
+2  A: 

There used to be Lilu by Yuri Rashkovskii, but it is no longer maintained. It is still available, though, so if you're interested you can maintain it yourself. (It's very little code, actually, and the templating part proper doesn't need to change anyway. The only part that probably does need to change is the integration into the Rails view engine, and that should be fairly trivial, now that Rails 3 actually does have a proper view engine.)

A newer system that leverages HTML5's data- attributes, is RuHL by Andrew Stone. Here's a quick taste (stolen from the website):

<!-- view.html -->
<html>
  <body>
    <p data-ruhl="say_hello"/>
  </body>
</html>

# model.rb
def say_hello
  "Hello World"
end

<!-- result.html -->
<html>
  <body>
    <p>Hello World</p>
  </body>
</html>
Jörg W Mittag
+2  A: 

Trellis is an attempt to create a component framework in Ruby. It's borrows more from Tapestry, but should have similarities to Wicket. http://www.trellisframework.org/

Brian Deterling
could this be used within rails or does it provide db methods on its own?
Karussell
I believe it's meant to run standalone, i.e. as a replacement for Rails. It would be cool if it plugged into the Rack framework like Sinatra though.
Brian Deterling