Logo

dev-resources.site

for different kinds of informations.

Papercraft - Composable Templating for Ruby

Published at
2/8/2022
Categories
ruby
template
html
Author
Sharon Rosner
Categories
3 categories in total
ruby
open
template
open
html
open
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>"

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.

Featured ones: