Skip to content
tonyganch edited this page Oct 21, 2012 · 3 revisions

Overview

Geddy can be used with many popular templating engines, including: EJS, Jade and Handlebars(Note: Geddy uses a custom version of EJS that's built in so you don't need to install anything to use it). Use of templating languages is completely transparent, you can even use multiple different languages at one time and it will work as if they were all the same language.

How to use

To use other templating languages, just change the extension and rewrite the views. Then Geddy will automatically use the new engine, if the engine isn't installed then an error will be thrown(Note: EJS will always be available as Geddy includes it's own implemenation).

Want to use multiple languages at once? Go ahead. You can write a layout in Jade a view in Handlebars and partials in EJS, and it'll work flawlessly.

Mustache is supported but it uses the Handlebars engine on the backend as it has many advantages over Mustache.

If you'd like a language to be added, make a issue with the language, the list of commonly used extensions and the npm package.

Examples

EJS layout:

<!DOCTYPE html>
<html>
  <head>
    <title>Geddy</title>
  </head>
  <body>
    <div id="container">
      <%- yield(); %>
    </div>
  </body>
</html>

EJS template:

<header>
  A Geddy template
</header>

Jade layout:

!!! 5
html
  head
    title Geddy
  body
    #container 
      != yield()

Jade template:

header A Geddy template

Handlebars layout:

<!DOCTYPE html>
<html>
  <head>
    <title>Geddy</title>
  </head>
  <body>
    <div id="container">
      {{{yield}}}
    </div>
  </body>
</html>

Handlebars template:

<header>
  A Geddy template
</header>

####Notes:

  • If you noticed in the Jade example, we're not using Jade's built in extends method for templates. This is because of how Geddy works internally, if you do use the extends method, just the layout is returned.
  • When using the yield method you'll notice you will have to disable escaping for it. The template is safe because they are processed at two different times.