Created
January 14, 2011 10:40
-
-
Save gunn/779462 to your computer and use it in GitHub Desktop.
Methods of creating data attributes in haml.
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
require "rubygems" | |
require "haml" | |
class Symbol | |
def -(string) | |
"#{self}-#{string}".intern | |
end | |
end | |
def method_missing name, *args, &block | |
name.to_s | |
end | |
puts Haml::Engine.new(DATA.read).render | |
__END__ | |
%h1 Methods for creating a data-edit attribute in haml | |
%h3 Official | |
%p{:data=>{:edit=>'whatever'}} content | |
%h3 Cleaner and flexible | |
%p{:'data-edit'=>'whatever'} content | |
%h3 Clean but inflexible | |
%p(data-edit='whatever') content | |
%h3 Possibly a mistake | |
%p{:data-edit=>'whatever'} content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment