Templating

This document only applies when using https://github.com/gobuffalo/buffalo/render.
Please see github.com/gobuffalo/plush for more details on the underlying templating package.

Buffalo defaults to using plush as its template engine.

General Usage

<h1><%= name %></h1>
<ul>
  <%= for (name) in names { %>
    <li><%= name %></li>
  <% } %>
</ul>
func IndexHandler(c buffalo.Context) error {
  c.Set("names", []string{"John", "Paul", "George", "Ringo"})
  return c.Render(200, r.HTML("index.html"))
}
<h1>Mark</h1>
<ul>
  <li>John</li>
  <li>Paul</li>
  <li>George</li>
  <li>Ringo</li>
</ul>

If Statements

<%= if (true) { %>
  <!-- render this -->
<% } %>

Else Statements

<%= if (false) { %>
  <!-- won't render this -->
<% } else { %>
  <!-- render this -->
<% } %>