diff --git a/README.rdoc b/README.rdoc index 95828663..9025bd94 100644 --- a/README.rdoc +++ b/README.rdoc @@ -49,7 +49,7 @@ check out the RDocs for the Haml and Sass modules. The most basic element of Haml is a shorthand for creating HTML tags: - %tagname{ :attr1 => 'value1', :attr2 => 'value2' } Contents + %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents No end-tag is needed; Haml handles that automatically. Adding class and id attributes is even easier. @@ -91,7 +91,7 @@ You can also put plain text as a child of an element: Hello, World! -It's even possible to embed Ruby code into Haml documents. +It's also possible to embed Ruby code into Haml documents. An equals sign, =, will output the result of the code. A hyphen, -, will run the code but not output the result. You can even use control statements diff --git a/lib/haml.rb b/lib/haml.rb index 99d06426..5bf3e197 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -100,7 +100,6 @@ require 'haml/version' # # ==== % # -# # The percent character is placed at the beginning of a line. # It's followed immediately by the name of an element, # then optionally by modifiers (see below), a space, @@ -223,65 +222,6 @@ require 'haml/version' # # # -# ==== [] -# -# Square brackets follow a tag definition and contain a Ruby object -# that is used to set the class and id of that tag. -# The class is set to the object's class -# (transformed to use underlines rather than camel case) -# and the id is set to the object's class, followed by its id. -# Because the id of an object is normally an obscure implementation detail, -# this is most useful for elements that represent instances of Models. -# Additionally, the second argument (if present) will be used as a prefix for -# both the id and class attributes. -# For example: -# -# # file: app/controllers/users_controller.rb -# -# def show -# @user = CrazyUser.find(15) -# end -# -# -# file: app/views/users/show.haml -# -# %div[@user, :greeting] -# %bar[290]/ -# Hello! -# -# is compiled to: -# -#
-# -# Hello! -#
-# -# ==== / -# -# The forward slash character, when placed at the end of a tag definition, -# causes the tag to be self-closed. -# For example: -# -# %br/ -# %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/ -# -# is compiled to: -# -#
-# -# -# Some tags are automatically closed, as long as they have no content. -# +meta+, +img+, +link+, +script+, +br+, and +hr+ tags are closed by default. -# This list can be customized by setting the :autoclose option (see below). -# For example: -# -# %br -# %meta{'http-equiv' => 'Content-Type', :content => 'text/html'} -# -# is also compiled to: -# -#
-# -# # ==== . and # # # The period and pound sign are borrowed from CSS. @@ -353,6 +293,65 @@ require 'haml/version' # # # +# ==== / +# +# The forward slash character, when placed at the end of a tag definition, +# causes the tag to be self-closed. +# For example: +# +# %br/ +# %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/ +# +# is compiled to: +# +#
+# +# +# Some tags are automatically closed, as long as they have no content. +# +meta+, +img+, +link+, +script+, +br+, and +hr+ tags are closed by default. +# This list can be customized by setting the :autoclose option (see below). +# For example: +# +# %br +# %meta{'http-equiv' => 'Content-Type', :content => 'text/html'} +# +# is also compiled to: +# +#
+# +# +# ==== [] +# +# Square brackets follow a tag definition and contain a Ruby object +# that is used to set the class and id of that tag. +# The class is set to the object's class +# (transformed to use underlines rather than camel case) +# and the id is set to the object's class, followed by its id. +# Because the id of an object is normally an obscure implementation detail, +# this is most useful for elements that represent instances of Models. +# Additionally, the second argument (if present) will be used as a prefix for +# both the id and class attributes. +# For example: +# +# # file: app/controllers/users_controller.rb +# +# def show +# @user = CrazyUser.find(15) +# end +# +# -# file: app/views/users/show.haml +# +# %div[@user, :greeting] +# %bar[290]/ +# Hello! +# +# is compiled to: +# +#
+# +# Hello! +#
+# # ==== > and < # # > and < give you more control over the whitespace near a tag.