Skip to content

Templates, layouts, and partials

hlb edited this page Apr 5, 2012 · 8 revisions

Fire.app provides HTML template languages like ERB, Haml and Markdown. If you do not want to use them, you can ignore this section.

Why should I use HTML template languages like ERB or Haml?

  1. You can use layout and partial.

    You can use layout and partial to control basic modules like header, footer, and navigation. Once you change the layout file, it applies across your whole site instantly.

  2. You can use template helpers.

  3. You can use Ruby code.

    You can use ruby code to make prototype faster. For example, if you want a <ul> list with 10 lis:

      <% 10.times do |x| %>
    • <%= x+1 %>: Loren Ipsum
    • <% end %>

How to

Page

If you name a file PATH/TO/FILENAME.html.erb, and open http://127.0.0.1:24681/PATH/TO/FILENAME.html, you will get compiled ERB output. If you name it FILENAME.haml.erb, it will use Haml.

Layout

There are two ways to use layout:

  1. put _layout.html.erb or _layout.haml.erb in the folder (or parent folder)
  2. use specific layout file

References

  • ERB
  • Haml
  • Markdown