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?
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?
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 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.
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.
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.