Goatee
What?
Inspired by mustache. Goatee wraps ERB to provide a framework-agnostic method of rendering views.
Config
require "goatee"
Goatee.configure do |c|
c.templates_directory = "/path/to/templates"
end
Basic Usage
Create a View
require "goatee"
module View
class Login < Goatee::View
def initialize(name)
@name = name
end
def render(name)
super "login"
end
def name
@name.capitalize
end
end
end
Create a Template
<h1>Login Page</h1>
<p>
Hello <%= name %>
</p>
Render it
require "view/login"
View::Login.new("batman").render
Partials
Include a partial by using the include keyword in an ERB template
<%= include "header" %>
<h1>Login Page</h1>
<p>
Hello <%= name %>
</p>
This will render the partial located at
<templates_directory>/includes/<partial_id>.erb