DEV Community

Sharon Rosner
Sharon Rosner

Posted on

Papercraft - Composable Templating for Ruby

Papercraft is a new Ruby gem I’ve been working on, that provides a new way to render HTML, XML and JSON using plain Ruby. Here’s what it looks like:

require 'papercraft'

greeter = Papercraft.html { |name| h1 "Hello, #{name}!" }
greeter.render('world') #=> "<h1>Hello, world!</h1>"
Enter fullscreen mode Exit fullscreen mode

Papercraft templates use explicit parameter passing in order to “bind” template variables, and use application and composition to combine templates in a variety of ways.

For more information on Papercraft, head over to the Noteflakes website.

Top comments (0)