public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Expand the FAQ.
nex3 (author)
Thu May 15 14:07:49 -0700 2008
commit  f489bd33c9a5babbfc9db8cfdd018492e8f682eb
tree    fd1c1b1a6eb6ad4f93d99133c4f71577c73510b7
parent  e2b61eb1e399f478be77c0d045c5d0abedb8279a
0
FAQ
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
0
@@ -1,5 +1,113 @@
0
 = Frequently Asked Questions
0
 
0
+== Haml
0
+
0
+=== How do I put a punctuation mark after an element, like "<tt>I like <strong>cake</strong>!</tt>"?
0
+
0
+Expressing the structure of a document
0
+and expressing inline formatting are two very different problems.
0
+Haml is mostly designed for structure,
0
+so the best way to deal with formatting is to leave it to other languages
0
+that are designed for it.
0
+You could use Textile:
0
+
0
+ %p
0
+ :textile
0
+ I like *cake*!
0
+
0
+or Markdown:
0
+
0
+ %p
0
+ :markdown
0
+ I like **cake**!
0
+
0
+or plain old XHTML:
0
+
0
+ %p I like <strong>cake</strong>!
0
+
0
+If you're inserting something that's generated by a helper, like a link,
0
+then it's even easier:
0
+
0
+ %p== I like #{link_to 'chocolate', 'http://franschocolates.com'}!
0
+
0
+=== How do I stop Haml from indenting the contents of my +pre+ and +textarea+ tags?
0
+
0
+Because Haml automatically indents the HTML source code,
0
+the contents of whitespace-sensitive tags like +pre+ and +textarea+
0
+can get screwed up.
0
+The solution is to replace the newlines inside these tags
0
+with HTML newline entities (<tt>&#x000A;</tt>),
0
+which Haml does using the Haml::Helpers#preserve and Haml::Helpers#find_and_preserve helpers.
0
+
0
+Normally, Haml will do this for you automatically
0
+when you're using a tag that needs it
0
+(this can be customized using the <tt>:preserve</tt> option;
0
+see the Options section of the {Haml reference}(../classes/Haml.html)).
0
+For example,
0
+
0
+ %p
0
+ %textarea= "Foo\nBar"
0
+
0
+will be compiled to
0
+
0
+ <p>
0
+ <textarea>Foo&#x000A;Bar</textarea>
0
+ </p>
0
+
0
+However, if a helper is generating the tag,
0
+Haml can't detect that and so you'll have to call +find_and_preserve+ yourself.
0
+You can also use <tt>~</tt>, which is the same as <tt>=</tt>
0
+except that it automatically runs +find_and_preserve+ on its input.
0
+For example:
0
+
0
+ %p= find_and_preserve "<textarea>Foo\nBar</textarea>"
0
+
0
+is the same as
0
+
0
+ %p~ "<textarea>Foo\nBar</textarea>"
0
+
0
+and renders
0
+
0
+ <p><textarea>Foo&#x000A;Bar</textarea></p>
0
+
0
+=== I have Haml installed. Why is Rails (only looking for <tt>.html.erb</tt> files | rendering Haml files as plain text | rendering Haml files as blank pages)?
0
+
0
+There are several reasons these things might be happening.
0
+First of all, make sure vendor/plugins/haml really exists
0
+and has an init.rb file in there.
0
+Then try restarting Mongrel or WEBrick or whatever you might be using.
0
+
0
+Finally, if none of these work,
0
+chances are you've got some localization plugin like Globalize installed.
0
+Such plugins often don't play nicely with Haml.
0
+Luckily, there's usually an easy fix.
0
+For Globalize, just edit globalize/lib/globalize/rails/action_view.rb
0
+and change
0
+
0
+ @@re_extension = /\.(rjs|rhtml|rxml)$/
0
+
0
+to
0
+
0
+ @@re_extension = /\.(rjs|rhtml|rxml|erb|builder|haml)$/
0
+
0
+For other plugins, a little searching will probably turn up a way to fix them as well.
0
+
0
+== Sass
0
+
0
+=== Can I use a variable from my controller in my Sass file?
0
+
0
+No. Sass files aren't views.
0
+They're compiled once into static CSS files,
0
+then left along until they're changed and need to be compiled again.
0
+Not only don't you want to be running a full request cycle
0
+every time someone requests a stylesheet,
0
+but it's not a great idea to put much logic in there anyway
0
+due to how browsers handle them.
0
+
0
+If you really need some sort of dynamic CSS,
0
+the best thing to do is put only the snippet you need to dynamically set
0
+in the +head+ of your HTML document.
0
+
0
 == You still haven't answered my question!
0
 
0
 Sorry! Try looking at the Haml or Sass references,

Comments

    No one has commented yet.