Skip to content

Instantly share code, notes, and snippets.

@jacquescrocker
Created August 9, 2012 02:36
Show Gist options
  • Save jacquescrocker/3300426 to your computer and use it in GitHub Desktop.
Save jacquescrocker/3300426 to your computer and use it in GitHub Desktop.
hamlbars_extensions
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