Ruby equiv of Perl's HTML::Template module?

C

ChrisO

Hopefully someone here fairly familiar with Perl can point me to a Ruby
HTML templating system that works like Perl's HTML::Template. The next
closest perferred equivalent would be Perl Template Toolkit. But I
really like HTML::Template a lot.

I'm relatively new to Ruby (very slight dabbling since v1.6 circa 2001),
so my opinions may not hold water, but I don't really consider eRuby a
templating system. Maybe someone can help me see how it's not anything
more than PHP or ASP except Ruby is used instead of PHP or VBScript...?

Anyway, my main interest is in finding something like Perl's
HTML::Template. Hopefully it exists somewhere in the Ruby world.

Thanks,
-ceo
 
G

Gavin Sinclair

Hopefully someone here fairly familiar with Perl can point me to a Ruby
HTML templating system that works like Perl's HTML::Template. The next
closest perferred equivalent would be Perl Template Toolkit. But I
really like HTML::Template a lot.

I'm relatively new to Ruby (very slight dabbling since v1.6 circa 2001),
so my opinions may not hold water, but I don't really consider eRuby a
templating system. Maybe someone can help me see how it's not anything
more than PHP or ASP except Ruby is used instead of PHP or VBScript...?

Anyway, my main interest is in finding something like Perl's
HTML::Template. Hopefully it exists somewhere in the Ruby world.

I don't think there's a direct port, but there are some Ruby HTML
templating libraries around (RDoc, cs/template, Amrita, ...). Can you
describe the benefits of the Perl solution? Maybe one of these (and there
are heaps more, I'm sure) is a close match.

I use and like Amrita for generating static pages. Can't comment on
anything else.

Cheers,
Gavin
 
K

Kent Sibilev

Take a look at rdoc/template.rb file which defines TemplatePage class.
I think it pretty much resembles HTML::Template system.

Cheers,
Kent.
 
A

Austin Ziegler

Take a look at rdoc/template.rb file which defines TemplatePage class.
I think it pretty much resembles HTML::Template system.

Also, Ruwiki has lib/ruwiki/template.rb that has an adapted form of
that (I have a new, updated version that is going in) which supports
labels as distinct from variables and some one-line forms of the
conditional and looping code.

-austin
 
C

Chris

Gavin said:
I don't think there's a direct port, but there are some Ruby HTML
templating libraries around (RDoc, cs/template, Amrita, ...). Can you
describe the benefits of the Perl solution?

I'm not sure I am able to accurately articulate what I perceive the
benefits to be. The main "advantage" that I feel -- it's kind of a
"gut" thing -- is that the templates are, in a logical way, truly only
markup. There is no "code" per se, loosely speaking. Strictly
speaking, I realize there are the loop and conditional tags, but still
it "feels" like only HTML markup. I really like that because the
separation between logic and presentation is about as good as it gets.

All my opinion of course but those that use HTML::Template in the Perl
world, I think would agree. I'm definitely going to check out some of
the suggestions. I've held this infatuation with Ruby for a long time,
and even adopted some "Ruby ways" in my Perl coding for a few years now.
I've decided the only real way to bridge the gap is to force myself to
stop using Perl (which I still really like) and just use Ruby full out.
So I'm trying to find things that ease the transition, like
HTML::Template. I can't afford a lot of downtime, which has been the
biggest strike against using Ruby -- I'm pretty fast, tight and accurate
in hitting targets using Perl (if I may be so bold). But there are
several "Wow!" factors in Ruby that keep me hanging around... wishing... :)

-ceo
 
K

Kurt Williams

The second URL here offers up an ruby equivalent of HTML::Template. I've
used the standard html-template in Ruby, which is philosophically
identical to Perl's HTML::Template, but uses different syntax for the
<TMPL_VAR> tags (that's the first URL below). Using it is still familiar
if you are a fan of HTML::Template.

The newer html-template2 claims to be compatible with HTML::Template,
though I haven't used it myself.

http://raa.ruby-lang.org/project/html-template/
http://raa.ruby-lang.org/project/html-template2/
 
M

Mark Probert

Hi, Chris.

Chris said:
So I'm trying to find things that ease the transition, like
HTML::Template. I can't afford a lot of downtime, which has been the
biggest strike against using Ruby -- I'm pretty fast, tight and
accurate in hitting targets using Perl (if I may be so bold). But
there are several "Wow!" factors in Ruby that keep me hanging
around... wishing... :)

I been using IOWA and finding it really powerful. Of course, if you are
going down the Web App route, almost all of which contain a templating
system, then there are a number of options to consider, like:

+ IOWA
+ Rails
+ Cerise

etc.

I guess it depends on the why you need the templates in the first place.
 
B

Brian Wisti

--- Chris said:
I'm not sure I am able to accurately articulate what I perceive the
benefits to be. The main "advantage" that I feel -- it's kind of a
"gut" thing -- is that the templates are, in a logical way, truly
only
markup. There is no "code" per se, loosely speaking. Strictly
speaking, I realize there are the loop and conditional tags, but
still
it "feels" like only HTML markup. I really like that because the
separation between logic and presentation is about as good as it
gets.

All my opinion of course but those that use HTML::Template in the
Perl
world, I think would agree. I'm definitely going to check out some
of
the suggestions. I've held this infatuation with Ruby for a long
time,
and even adopted some "Ruby ways" in my Perl coding for a few years
now.
I've decided the only real way to bridge the gap is to force myself
to
stop using Perl (which I still really like) and just use Ruby full
out.
So I'm trying to find things that ease the transition, like
HTML::Template. I can't afford a lot of downtime, which has been the

biggest strike against using Ruby -- I'm pretty fast, tight and
accurate
in hitting targets using Perl (if I may be so bold). But there are
several "Wow!" factors in Ruby that keep me hanging around...
wishing... :)

-ceo

You can always take a poke at my own PageTemplate library. It was a
sort of self-instructional project designed (ha! "Designed"? Right!) to
address the homesickness I felt when using Ruby kept me away from
HTML::Template.

http://coolnamehere.com/products/pagetemplate/

You may find that it is incredibly raw and simplistic, and it might not
even be what you were thinking of, but hey - what's one more templating
library out there? Feel free to poke at it all you want :)

Kind Regards,

Brian Wisti
http://coolnamehere.com/
 
C

ChrisO

Kurt said:
The second URL here offers up an ruby equivalent of HTML::Template. I've
used the standard html-template in Ruby, which is philosophically
identical to Perl's HTML::Template, but uses different syntax for the
<TMPL_VAR> tags (that's the first URL below). Using it is still familiar
if you are a fan of HTML::Template.

The newer html-template2 claims to be compatible with HTML::Template,
though I haven't used it myself.

http://raa.ruby-lang.org/project/html-template/
http://raa.ruby-lang.org/project/html-template2/

Perfect. I'll check them out!

-ceo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top