Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Created April 13, 2009 18:17
Show Gist options
  • Save ryanfb/94591 to your computer and use it in GitHub Desktop.
Save ryanfb/94591 to your computer and use it in GitHub Desktop.
Recursive Haml abuse
- p = Proc.new do |element, hidden, block|
- tab_up
%div{:id => element.div_id, :class => element.error_class, :style => "display:#{hidden ? 'none' : ''};"}
= element.name + " (" + element.length.to_s + " instances)"
.toggle_button
%a{:onclick => "toggle_div('#{element.div_id}-examples');"}
Examples
.examples{:id => element.div_id + "-examples", :style => "display:none;"}
- for example in element.examples
.filename
= example.xml_file
.xml
%code= html_escape(example.xml_content)
.leiden
= example.text
- if element.children?
Children:
- for child in element.children
.toggle_button
%a{:onclick => "toggle_div('#{child.div_id}');"}
= child.name
- block.call(child, true, block)
- tab_down
- for ddb_element in ddb_elements
- p.call(ddb_element, false, p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment