Ruby phlex.fun

A framework for building fast, reusable, testable views in pure Ruby  ↦

Phlex views are “plain old Ruby objects” — templates are methods and HTML tags are method calls. If you know how to define a class with a method that calls another method, you know how to use Phlex.

When it comes to API usability, Ruby is so tough to beat. This looks actually fun to use!

class Nav < Phlex::HTML
  def template
    nav(class: "main-nav") {
      ul {
        li { a(href: "/") { "Home" } }
        li { a(href: "/about") { "About" } }
        li { a(href: "/contact") { "Contact" } }
      }
    }
  end
end

Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00