DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Custom Captures

  • submit to reddit
        I made a layout with some slightly ugly code for making rounded boxes with CSS and HTML, and wanted a way to automate the boxes. I had thought of having two functions to print starting and ending code, but this seems nicer.

This goes with the other application helpers:

  def rounded_box(&block)
    concat '<div class="rounded"><div class="top"></div><div class="body">' + capture(&block) + '</div><div class="bottom"></div></div>', block.binding

This goes in a view:

<% rounded_box do %>

... stuff to put in the rounded box ...

<% end %>


Snippets Manager replied on Mon, 2012/05/07 - 1:12pm

Thank-you! That's exactly what I've been trying to do for quite some time.

Snippets Manager replied on Mon, 2012/05/07 - 1:12pm

ooh. i like that. i could probably use that.