Never been to DZone Snippets before?

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

Custom captures (See related posts)

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
  end


This goes in a view:

<% rounded_box do %>

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

<% end %>

Comments on this post

mattm posts on Jun 17, 2005 at 01:41
ooh. i like that. i could probably use that.
canadaduane posts on Jun 17, 2005 at 03:46
Thank-you! That's exactly what I've been trying to do for quite some time.

You need to create an account or log in to post comments to this site.


Click here to browse all 4834 code snippets

Related Posts