Created
May 23, 2011 19:07
-
-
Save chriseppstein/987308 to your computer and use it in GitHub Desktop.
This gist shows some approaches for using haml without repeating inner content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for(:inner_content) do | |
= render :partial => "inner_content" | |
- if some_condition | |
%outertag1= yield :inner_content | |
- else | |
%outertag2= yield :inner_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- haml_tag(some_condition ? "outertag1" : "outertag2") do | |
= render :partial => "inner_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if some_condition | |
%outertag1= render :partial => "inner_content" | |
- else | |
%outertag2= render :partial => "inner_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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