Getting Started
Request handling
- Routing
- Action Controller
- Resources
- Context
- Request Binding
- Middleware
- Error Handling
- Sessions
- Cookies
Frontend
Database
- Getting started with Pop
- Soda CLI
- Database Configuration
- Buffalo Integration
- Models
- Generators
- Migrations
- Fizz
- Mutations
- Querying
- Raw Queries
- Callbacks
- Scoping
- Associations and Relationships
- One to one associations
- One to many associations
Guides
- API Applications
- File Uploads
- Background Job Workers
- Mailers
- Tasks
- Plugins
- Local Authentication
- Third Party Authentication
- Events
- Go Modules
- Localization
- Logging
- Template Engines
- Testing
- Videos
Deploy
Templating
Frontend
Templating
Buffalo defaults to using plush as its template engine.
General Usage
// templates/index.html
<h1><%= name %></h1>
<ul>
<%= for (name) in names { %>
<li><%= name %></li>
<% } %>
</ul>
// actions/index.go
func IndexHandler(c buffalo.Context) error {
c.Set("name", "Mark")
c.Set("names", []string{"John", "Paul", "George", "Ringo"})
return c.Render(200, r.HTML("index.html"))
}
// output
<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 -->
<% } %>