From 575e92d2d0ea75a8e5594a001885cbfc294ed4a3 Mon Sep 17 00:00:00 2001 From: nex3 Date: Wed, 19 Dec 2007 11:53:19 +0000 Subject: [PATCH] Document Haml method-attributes. git-svn-id: svn://hamptoncatlin.com/haml/trunk@704 7063305b-7217-0410-af8c-cdc13e5119b9 --- lib/haml.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/haml.rb b/lib/haml.rb index 7a530ce8..eebbd394 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -143,6 +143,45 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir) # # +# +# A Ruby method call that returns a hash +# can be substituted for the hash contents. +# For example, Haml::Helpers defines the following method: +# +# def html_attrs(lang = 'en-US') +# {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang} +# end +# +# This can then be used in Haml, like so: +# +# %html{html_attrs('fr-fr')} +# +# This is compiled to: +# +# +# +# +# You can use as many such attribute methods as you want +# by separating them with commas, +# like a Ruby argument list. +# All the hashes will me merged together, from left to right. +# For example, if you defined +# +# def hash1 +# {:bread => 'white', :filling => 'peanut butter and jelly'} +# end +# +# def hash2 +# {:bread => 'whole wheat'} +# end +# +# then +# +# %sandwich{hash1, hash2, :delicious => true}/ +# +# would compile to: +# +# # # ==== [] #