Is it there a Ruby equivalent of Java's Wicket?
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 ?
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>
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/
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
精彩评论