ExpressTemplates - Reusable view components in Ruby

Write templates in Ruby

Use a declarative style of Ruby to write template code based on Arbre.

content_for :title, "Hello, world"

div {
  h1 "#{hello}"
  p 'Find me in app/views/hello/show.html.et'
}

Learn more

Use Rails' form tag helpers

form(action: invites_path, method: "POST") {
  div(class: 'form-group') {
    label_tag(:invite_code, "Invite Code:")
    text_field_tag('invite_code', '', class: 'form-control')
  }
}

Compose templates to build components

Components are reusable pieces of user interface code. See Express UI.

class PageHeader < ExpressTemplates::Components::Base

  contains -> {
    if content_for?(:page_header)
      h1 {
        content_for(:page_header)
      }
    end
    if content_for?(:page_header_lead)
      para(class: 'lead') {
        content_for(:page_header_lead)
      }
    end
  }
end

Learn more

Philosophy

  1. It's just Ruby.

  2. Write less markup code with reusable components.

Learn more

Download and installation

Download the latest version of ExpressTemplates from RubyGems:

$ gem install express_templates

Source code is on GitHub as part of the express-gems project:

License

ExpressTemplates is released under the MIT license: