Which template for ruby-begin project?

Hi,

Once we used Template::Toolkit (Perl) and Smarty (PHP) for templates,
both are great.
Now if we begin a new web project with Ruby, and choose the Sinatra
framework, what's the corrensponding template for it?
And I believe Sinatra is lighter and easier to learn than Rails, is it?

Thanks.

Ruby Newbee wrote:

Hi,

Once we used Template::Toolkit (Perl) and Smarty (PHP) for templates,
both are great.
Now if we begin a new web project with Ruby, and choose the Sinatra
framework, what's the corrensponding template for it?
And I believe Sinatra is lighter and easier to learn than Rails, is it?

Thanks.

Most of the people I know use HAML ( http://haml-lang.com/\). Erb and
Mustache( http://github.com/defunkt/mustache-sinatra-example\) are
options too.

From Sinatra Book ->
http://www.sinatrarb.com/book.html#template_languages

···

--
Posted via http://www.ruby-forum.com/\.

Ruby Newbee wrote:

And I believe Sinatra is lighter and easier to learn than Rails, is it?

Yes - in the sense that it's very much smaller, and you can easily grasp
the whole of it.

You'll probably end up writing your own helper methods for the things
you need - which in many cases is easier that wading through Rails APIs
to try and find whether Rails has something pre-existing that you could
use, and how to use it.

As regards templates: note the following comment from the HEAD
(unreleased) version of Sinatra.

= 1.0 / unreleased

* Sinatra now uses Tilt <http://github.com/rtomayko/tilt&gt; for rendering
   templates. This adds support for template caching, consistent
   template backtraces, and support for new template engines, like
   markaby and liquid.

So that's a good place to look at available templating options.

For generating (X)HTML I use HAML - you'll either love it or hate it. I
love it because my templates are tiny, I never have to close any tags,
and I'm always guaranteed well-formed XML.

···

--
Posted via http://www.ruby-forum.com/\.

Oh, and for an example of a 'larger' Sinatra app, look at Vegas:

I don't like the default choice of templating language, but you can
steal ideas about how to bolt together things like ActiveRecord and
unit/functional tests.

On the subject of testing, have a look at Cucumber too, as that should
also play nicelyu with Sinatra, according to
http://wiki.github.com/aslakhellesoy/cucumber/sinatra

···

--
Posted via http://www.ruby-forum.com/.

Thank you Brian for the useful information.

···

On Sat, Dec 12, 2009 at 9:14 PM, Brian Candler <b.candler@pobox.com> wrote:

Ruby Newbee wrote:

And I believe Sinatra is lighter and easier to learn than Rails, is it?

Yes - in the sense that it's very much smaller, and you can easily grasp
the whole of it.

You'll probably end up writing your own helper methods for the things
you need - which in many cases is easier that wading through Rails APIs
to try and find whether Rails has something pre-existing that you could
use, and how to use it.

As regards templates: note the following comment from the HEAD
(unreleased) version of Sinatra.

Brian Candler wrote:
[...]

For generating (X)HTML I use HAML - you'll either love it or hate it. I
love it because my templates are tiny, I never have to close any tags,
and I'm always guaranteed well-formed XML.

Unfortunately, you don't want well-formed XML for Web apps -- you want
well-formed HTML4. XHTML never quite fulfilled its promise, and is not
really supported in IE. (No, serving it as HTML is not the answer -- the
syntaxes are just incompatible enough.) I used to serve XHTML from Web
apps, but I've changed them to HTML now that I understand the problems.

Fortunately, with Haml, this is just a question of tweaking an option or
two. With Rails, you also need the html_output plugin to get the
helpers playing along; I'm not sure about Sinatra.

Best,

···

--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/\.