RubyFlow The Ruby and Rails community linklog

First Class Views With Hoshi

Pete Elmore has released Hoshi. “Hoshi is a library for creating real first-class HTML/XML views. So, unlike template libraries, you can take advantage of mixins, inheritance, and all the other wonderful features of Ruby’s object system.”

Comments

I can’t find it on RubyForge currently, I think they just registered the project name and are waiting for approval.

It also appears you’ll need Ruby 1.9 for Hoshi, since it’s passing blocks to blocks (which is a totally rad feature btw). This library looks super cool.

GGAAARRRRRRR!

It actually works under 1.8.7, so, win-win. Regarding the rubyforge thing, it is still pending. I’m sure in the wake of rubyconf, there are probably at least 9,001 gems waiting.

(By the way, the above petesez is a co-worker.)

Looks interesting. How does it compare to Erector?

Erector is a Builder-like view framework, inspired by Markaby but overcoming some of its flaws. In Erector all views are objects, not template files, which allows the full power of object-oriented programming (inheritance, modular decomposition, encapsulation) in views. See the rdoc for the Erector::Widget class to learn how to make your own widgets, and visit the project site at <http://erector.rubyforge.org> for more documentation.

Why and how do my posts always seem to get edited?

Who took out the blockquote tag and my snarky “Nuff said”?

It seems weird that I can’t change my own posts, but they seem to get edited by others….

@Wayne - Erector is currently Rails only.

Ofcourse the focus is completely different but for raw HTML generation, Haml is the best.

There are a ton of similar libraries at this point. Naturally, I’m still most partial to the one I wrote: http://instrument.rubyforge.org/

The main advantage versus Markaby is that within blocks, you aren’t in the builder object, you’re in your class instance. So you can expect things like inheritance, mixins, instance variables, etc. to work normally.

Versus Erector, the advantage is that a class isn’t limited to implementing a single view (or view component). You just call the view method (with arguments if you like) like a normal method. Ex: view.show( entry ).

Versus HAML, Hoshi is just Ruby, which makes it far more flexible, extensible, etc. You can still keep your markup quite neat. Obviously, if you want to expose templates to users, this is less attractive than HAML, but otherwise, I think the pure Ruby approach is more attractive.

Instrument (and Cell) are more component-oriented, which a very different, but also very compelling approach, IMHO.

In effect, the point of Hoshi was to deliver a pure Ruby view implementation that did not have any of the disadvantages of Markaby. I think Pete has knocked it out of the part. In short, Hoshi is the new Markaby. :) For Waves, Hoshi will be the “default” view technology.

Hoshi looks interesting - unfortunately it seems to have fallen into the abyss. Looking at the github page no one has touched the source since last summer. Erector, on the other hand, was updated 2 days ago, and after digging through it I dont see why I couldnt write my own custom module to do exactly what Dan said (view.show(@post)) - its pure ruby, with the same inheritance of modules and classes, really anything is possible

Note the become hunting for stylish affordable replica watches, within economical fees, one way to secure everything that contemplating is without a doubt to check affordable watches enjoy much of our a number of exquisite Burberry replacement plastic swiss replica watches. L. H Theis is definitely the novelist about this guide at Large Burberry affordable bags.These types of Replica Rolex watches are sold at a considerably decreased cost range and are readily out there towards the basic public.

@Anonymous Coward: I only touch the code when it breaks. :) When you posted that comment, I was still actively using Hoshi in production environments, and it’s still working fine. The sparse updates only mean that the code didn’t break; it’s not a meaningful metric for a project’s usefulness.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in