Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chriseppstein/987308 to your computer and use it in GitHub Desktop.
Save chriseppstein/987308 to your computer and use it in GitHub Desktop.
This gist shows some approaches for using haml without repeating inner content
- content_for(:inner_content) do
= render :partial => "inner_content"
- if some_condition
%outertag1= yield :inner_content
- else
%outertag2= yield :inner_content
- haml_tag(some_condition ? "outertag1" : "outertag2") do
= render :partial => "inner_content"
- if some_condition
%outertag1= render :partial => "inner_content"
- else
%outertag2= render :partial => "inner_content"
- if some_condition
= "<outertag1>"
- else
= "<outertag2>"
= render :partial => "inner_content"
- if some_condition
= "</outertag1>"
- else
= "</outertag2>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment