diff --git a/README b/README
index 5333b261..d20674f6 100644
--- a/README
+++ b/README
@@ -22,6 +22,9 @@ HAML was originally created by Hampton Catlin (hcatlin). Help with the
Ruby On Rails implementation and much of the documentation by
Jeff Hardy (packagethief).
+Nathan Weizenbaum (Nex3) contribued the buffered-engine code along with many
+other enhancements including the silent-line syntax ("-").
+
If you use this software, you must pay Hampton a compliment. Say something
nice about it. Beyond that, the implementation is licensed under the MIT
License. Ok, fine, I guess that means compliments aren't *required*.
@@ -50,72 +53,185 @@ is compiled to:
== Characters with meaning to Haml
-Haml responds to certain special characters. To create an element in the form of
- use the % character, immediately followed
-by the element name. To specify attributes, include a hash of attributes inside
-curly braces. Example:
+Various characters, when placed at a certain point in a line, instruct HAML
+to render different types of things.
+
+=== XHTML Tags
+
+These characters render XHTML tags.
+
+==== %
+
+This element 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,
+and text to be rendered inside the element. It creates an element in the form of
+. For example:
%one
- %meta{:content => 'something'}/
%two
%three Hey there
-
+
is compiled to:
-
Hey there
Any string is a valid element name; Haml will automatically generate opening and
-closing tags for any element. When you want to force the output of a
-self-closing tag, use the forward slash character. Example:
+closing tags for any element.
- %br/ # =>
- %meta{:http-equiv => 'Content-Type', :content => 'text/html'}/
- # =>
+==== {}
-HTML div elements are assumed when no %tag is present and the line is
-preceeded by either the # or the . characters. This convention
-uses familiar CSS semantics: # denotes the id of the element,
-. denotes its class name. Example:
+Brackets represent a Ruby hash that is used for specifying the attributes of an
+element. It is literally evaluated as a Ruby hash, so logic will work in it. At
+the moment, though, it doesn't see local variables. The hash is placed after
+the tag is defined. For example:
- #collection
- .item
- Broken record album
-
-is the same as:
+ %head{ :name => "doc_head" }
+ %script{ 'type' => "text/" + "javascript", :src => "javascripts/script_#{2 + 7}" }
- %div{:id => collection}
- %div{:class => 'item'}
- Broken record album
+is compiled to:
-and is comiled to:
+
+
+
+
+==== []
-
-
Broken record album
+Square brackets follow a tag definiton 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. For example:
+
+ # file: app/controllers/users_controller.rb
+
+ def show
+ @user = CrazyUser.find(15)
+ end
+
+ # file: app/views/users/show.haml
+
+ %div[@user]
+ %bar[290]/
+ Hello!
+
+is compiled to:
+
+
+
+ Hello!
-There is a shortcut when you want to specify either the id or class attributes
-of an element: follow the element name with either the
# or the
-
. characters. Example:
+This is based off of DHH's SimplyHelpful syntax as presented at RailsConf Europe 2006.
- #things
+==== /
+
+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:
+
+
+
+
+==== . and #
+
+The period and pound sign are borrowed from CSS and used as shortcuts to specify the
+
class and
id attributes of an element, respectively. They are
+placed immediately after the tag, and before an attributes hash. For example:
+
+ div#things
%span#rice Chicken Fried
- %p.beans The magical fruit
+ %p.beans{ :food => 'true' } The magical fruit
+ %h1.class#id La La La
is compiled to:
Chicken Fried
-
The magical fruit
+
The magical fruit
+
La La La
-=== Specifying a document type
+==== Assumed Divs
-When describing xhtml documents with Haml, you can have a document type
+Because the div element is used so often, it is the default element. If you only
+define a class and/or id using the
. or
# syntax, a div element
+is automatically used. For example:
+
+ #collection
+ .item
+ .description What a cool item!
+
+is the same as:
+
+ %div{:id => collection}
+ %div{:class => 'item'}
+ %div{:class => 'description'} What a cool item!
+
+and is compiled to:
+
+
+
Broken record album
+
What a cool item!
+
+
+==== = and ~
+
+
= and
~ are placed at the end of a tag definition, after class,
+id, and attribute declarations. They're just shortcuts for inserting Ruby code
+into an element. They work the same as
= and
~ without a tag;
+see below for documentation of those. For example:
+
+ %p= "hello"
+ %h1~ 1 + 2
+
+is the same as:
+
+ %p
+ = "hello"
+ %h1
+ ~ 1 + 2
+
+and is compiled to:
+
+
+ hello
+
+
+ 3
+
+
+=== XHTML Helpers
+
+==== No Special Character
+
+If no special character appears at the beginning of a line, it is rendered as plain
+text. For example:
+
+ %gee
+ %whiz
+ Wow this is cool!
+
+is compiled to:
+
+
+
+ Wow this is cool!
+
+
+
+==== !!!
+
+When describing XHTML documents with Haml, you can have a document type
generated automatically by including the characters
!!! as the first
line in your document. Example:
@@ -139,11 +255,158 @@ is compiled to:
Sign my guestbook