# Which template for ruby-begin project?

**URL:** <https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130>\
**Category:** Ruby\
**Created:** [December 12, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130 "2009-12-12T12:03:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/1 "2009-12-12T12:03:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/2 "2009-12-12T12:26:40Z")

</div>

Ruby N. 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/](http://haml-lang.com/)). Erb and  
Mustache( [GitHub - defunkt/mustache-sinatra-example: An example of using Mustache in a Sinatra app.](http://github.com/defunkt/mustache-sinatra-example)) are  
options too.

From Sinatra Book →   
[http://www.sinatrarb.com/book.html#template\_languages](http://www.sinatrarb.com/book.html#template_languages)

---

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 2:14pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/3 "2009-12-12T14:14:53Z")

</div>

Ruby N. 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](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.

---

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 2:33pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/4 "2009-12-12T14:33:14Z")

</div>

On Sat, Dec 12, 2009 at 9:14 PM, Brian C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

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

Thank you Brian for the useful information.

---

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 2:20pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/5 "2009-12-12T14:20:00Z")

</div>

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

> **[GitHub - alexch/vegas: template application demonstrating how to get Rails 3...](https://github.com/alexch/vegas)**
>
> template application demonstrating how to get Rails 3 pluggability without waiting for Rails 3 (Sinatra FTW) - GitHub - alexch/vegas: template application demonstrating how to get Rails 3 pluggabil...

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](http://wiki.github.com/aslakhellesoy/cucumber/sinatra)

---

<div class="post-metadata">

**Author:** ![rubynut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@rubynut](https://www.ruby-forum.com/u/rubynut)\
**Post date:** [December 12, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/which-template-for-ruby-begin-project/180130/6 "2009-12-12T15:23:22Z")

</div>

Brian C. 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](http://www.marnen.org)  
removed\_email\_address@domain.invalid
