Created
August 9, 2012 02:36
-
-
Save jacquescrocker/3300426 to your computer and use it in GitHub Desktop.
hamlbars_extensions
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
module Haml | |
module Helpers | |
module HamlbarsExtensions | |
def handlebars_if(expression, &block) | |
handlebars("if #{expression}", &block) | |
end | |
alias hb_if handlebars_if | |
def handlebars_else(&block) | |
if block.respond_to? :call | |
content = capture_haml(&block) | |
else | |
content = "" | |
end | |
"{{{#else}}}#{content.strip}" | |
end | |
alias hb_else handlebars_else | |
def handlebars_unless(expression, &block) | |
handlebars("unless #{expression}", &block) | |
end | |
alias hb_unless handlebars_unless | |
def handlebars_each(expression, &block) | |
handlebars("each #{expression}", &block) | |
end | |
alias hb_each handlebars_each | |
def handlebars_with(expression, &block) | |
handlebars("with #{expression}", &block) | |
end | |
alias hb_with handlebars_with | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment