Wunderbar on Rails
Usage: add wunderbar
and nokogiri
to your Gemfile
and run bundle install
. Template extensions supported are _html
and _json
. Examples: view, layout, json.
Note that as Rails layouts and views are predicated on the assumption that output is produced by concatenating text, one must use _ yield
instead of simply yield
. I have noticed that this may lose blank lines in the process, which apparently is a known issue with Nokogiri. Not a problem if the layout is erb, but then you lose the unified indentation that you get if you have a layout using _html
.
On the plus side, Wunderbar will note when the first argument to a call which creates an element is html_safe?
and will treat it as markup. An example of where this is useful would be in the _td link_to
calls below.
_h1_ 'Listing products' _table do _tr do _th 'Title' _th _th _th end @products.each do |product| _tr_ do _td product.title _td link_to 'Show', product _td link_to 'Edit', edit_product_path(product) _td link_to 'Destroy', product, confirm: 'Are you sure?', method: :delete end end end _br_ _ link_to 'New Product', new_product_path