mack-haml 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/lib/gems.rb +13 -0
  2. data/lib/gems/haml-2.0.4/VERSION +1 -0
  3. data/lib/gems/haml-2.0.4/bin/css2sass +7 -0
  4. data/lib/gems/haml-2.0.4/bin/haml +9 -0
  5. data/lib/gems/haml-2.0.4/bin/html2haml +7 -0
  6. data/lib/gems/haml-2.0.4/bin/sass +8 -0
  7. data/lib/gems/haml-2.0.4/lib/haml.rb +1040 -0
  8. data/lib/gems/haml-2.0.4/lib/haml/buffer.rb +239 -0
  9. data/lib/gems/haml-2.0.4/lib/haml/engine.rb +265 -0
  10. data/lib/gems/haml-2.0.4/lib/haml/error.rb +22 -0
  11. data/lib/gems/haml-2.0.4/lib/haml/exec.rb +364 -0
  12. data/lib/gems/haml-2.0.4/lib/haml/filters.rb +275 -0
  13. data/lib/gems/haml-2.0.4/lib/haml/helpers.rb +453 -0
  14. data/lib/gems/haml-2.0.4/lib/haml/helpers/action_view_extensions.rb +45 -0
  15. data/lib/gems/haml-2.0.4/lib/haml/helpers/action_view_mods.rb +179 -0
  16. data/lib/gems/haml-2.0.4/lib/haml/html.rb +227 -0
  17. data/lib/gems/haml-2.0.4/lib/haml/precompiler.rb +805 -0
  18. data/lib/gems/haml-2.0.4/lib/haml/template.rb +51 -0
  19. data/lib/gems/haml-2.0.4/lib/haml/template/patch.rb +58 -0
  20. data/lib/gems/haml-2.0.4/lib/haml/template/plugin.rb +72 -0
  21. data/lib/gems/haml-2.0.4/lib/sass.rb +863 -0
  22. data/lib/gems/haml-2.0.4/lib/sass/constant.rb +214 -0
  23. data/lib/gems/haml-2.0.4/lib/sass/constant/color.rb +101 -0
  24. data/lib/gems/haml-2.0.4/lib/sass/constant/literal.rb +54 -0
  25. data/lib/gems/haml-2.0.4/lib/sass/constant/nil.rb +9 -0
  26. data/lib/gems/haml-2.0.4/lib/sass/constant/number.rb +87 -0
  27. data/lib/gems/haml-2.0.4/lib/sass/constant/operation.rb +30 -0
  28. data/lib/gems/haml-2.0.4/lib/sass/constant/string.rb +22 -0
  29. data/lib/gems/haml-2.0.4/lib/sass/css.rb +394 -0
  30. data/lib/gems/haml-2.0.4/lib/sass/engine.rb +466 -0
  31. data/lib/gems/haml-2.0.4/lib/sass/error.rb +35 -0
  32. data/lib/gems/haml-2.0.4/lib/sass/plugin.rb +169 -0
  33. data/lib/gems/haml-2.0.4/lib/sass/plugin/merb.rb +56 -0
  34. data/lib/gems/haml-2.0.4/lib/sass/plugin/rails.rb +24 -0
  35. data/lib/gems/haml-2.0.4/lib/sass/tree/attr_node.rb +53 -0
  36. data/lib/gems/haml-2.0.4/lib/sass/tree/comment_node.rb +20 -0
  37. data/lib/gems/haml-2.0.4/lib/sass/tree/directive_node.rb +46 -0
  38. data/lib/gems/haml-2.0.4/lib/sass/tree/node.rb +42 -0
  39. data/lib/gems/haml-2.0.4/lib/sass/tree/rule_node.rb +89 -0
  40. data/lib/gems/haml-2.0.4/lib/sass/tree/value_node.rb +16 -0
  41. data/lib/gems/haml-2.0.4/rails/init.rb +1 -0
  42. data/lib/mack-haml.rb +1 -0
  43. metadata +65 -16
@@ -0,0 +1,51 @@
1
+ require 'haml/engine'
2
+
3
+ module Haml
4
+ class Template
5
+ class << self
6
+ @@options = {}
7
+
8
+ # Gets various options for Haml. See README.rdoc for details.
9
+ def options
10
+ @@options
11
+ end
12
+
13
+ # Sets various options for Haml. See README.rdoc for details.
14
+ def options=(value)
15
+ @@options = value
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ # Decide how we want to load Haml into Rails.
22
+ # Patching was necessary for versions <= 2.0.1,
23
+ # but we can make it a normal handler for higher versions.
24
+ if defined?(ActionView::TemplateHandler)
25
+ require 'haml/template/plugin'
26
+ else
27
+ require 'haml/template/patch'
28
+ end
29
+
30
+ if defined?(RAILS_ROOT)
31
+ # Update init.rb to the current version
32
+ # if it's out of date.
33
+ #
34
+ # We can probably remove this as of v1.9,
35
+ # because the new init file is sufficiently flexible
36
+ # to not need updating.
37
+ rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
38
+ haml_init_file = Haml.scope('init.rb')
39
+ begin
40
+ if File.exists?(rails_init_file)
41
+ require 'fileutils'
42
+ FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
43
+ end
44
+ rescue SystemCallError
45
+ warn <<END
46
+ HAML WARNING:
47
+ #{rails_init_file} is out of date and couldn't be automatically updated.
48
+ Please run `haml --rails #{File.expand_path(RAILS_ROOT)}' to update it.
49
+ END
50
+ end
51
+ end
@@ -0,0 +1,58 @@
1
+ # This file makes Haml work with Rails
2
+ # by monkeypatching the core template-compilation methods.
3
+ # This is necessary for versions <= 2.0.1 because the template handler API
4
+ # wasn't sufficiently powerful to deal with caching and so forth.
5
+
6
+ # This module refers to the ActionView module that's part of Ruby on Rails.
7
+ # Haml can be used as an alternate templating engine for it,
8
+ # and includes several modifications to make it more Haml-friendly.
9
+ # The documentation can be found
10
+ # here[http://rubyonrails.org/api/classes/ActionView/Base.html].
11
+ module ActionView
12
+ class Base # :nodoc:
13
+ def delegate_template_exists_with_haml(template_path)
14
+ template_exists?(template_path, :haml) && [:haml]
15
+ end
16
+ alias_method :delegate_template_exists_without_haml, :delegate_template_exists?
17
+ alias_method :delegate_template_exists?, :delegate_template_exists_with_haml
18
+
19
+ def compile_template_with_haml(extension, template, file_name, local_assigns)
20
+ return compile_haml(template, file_name, local_assigns) if extension.to_s == "haml"
21
+ compile_template_without_haml(extension, template, file_name, local_assigns)
22
+ end
23
+ alias_method :compile_template_without_haml, :compile_template
24
+ alias_method :compile_template, :compile_template_with_haml
25
+
26
+ def compile_haml(template, file_name, local_assigns)
27
+ render_symbol = assign_method_name(:haml, template, file_name)
28
+ locals = local_assigns.keys
29
+
30
+ @@template_args[render_symbol] ||= {}
31
+ locals_keys = @@template_args[render_symbol].keys | locals
32
+ @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h }
33
+
34
+ options = Haml::Template.options.dup
35
+ options[:filename] = file_name || 'compiled-template'
36
+
37
+ begin
38
+ Haml::Engine.new(template, options).def_method(CompiledTemplates, render_symbol, *locals_keys)
39
+ rescue Exception => e
40
+ if logger
41
+ logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
42
+ logger.debug "Backtrace: #{e.backtrace.join("\n")}"
43
+ end
44
+
45
+ base_path = if defined?(extract_base_path_from)
46
+ # Rails 2.0.x
47
+ extract_base_path_from(file_name) || view_paths.first
48
+ else
49
+ # Rails <=1.2.6
50
+ @base_path
51
+ end
52
+ raise ActionView::TemplateError.new(base_path, file_name || template, @assigns, template, e)
53
+ end
54
+
55
+ @@compile_time[render_symbol] = Time.now
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,72 @@
1
+ # :stopdoc:
2
+ # This file makes Haml work with Rails
3
+ # using the > 2.0.1 template handler API.
4
+
5
+ module Haml
6
+ class Plugin < ActionView::TemplateHandler
7
+ include ActionView::TemplateHandlers::Compilable if defined?(ActionView::TemplateHandlers::Compilable)
8
+
9
+ def compile(template)
10
+ options = Haml::Template.options.dup
11
+
12
+ # template is a template object in Rails >=2.1.0,
13
+ # a source string previously
14
+ if template.respond_to? :source
15
+ options[:filename] = template.filename
16
+ source = template.source
17
+ else
18
+ source = template
19
+ end
20
+
21
+ Haml::Engine.new(source, options).send(:precompiled_with_ambles, [])
22
+ end
23
+
24
+ def cache_fragment(block, name = {}, options = nil)
25
+ @view.fragment_for(block, name, options) do
26
+ eval("_hamlout.buffer", block.binding)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
33
+ ActionView::Template
34
+ else
35
+ ActionView::Base
36
+ end.register_template_handler(:haml, Haml::Plugin)
37
+
38
+ # In Rails 2.0.2, ActionView::TemplateError took arguments
39
+ # that we can't fill in from the Haml::Plugin context.
40
+ # Thus, we've got to monkeypatch ActionView::Base to catch the error.
41
+ if ActionView::TemplateError.instance_method(:initialize).arity == 5
42
+ class ActionView::Base
43
+ def compile_template(handler, template, file_name, local_assigns)
44
+ render_symbol = assign_method_name(handler, template, file_name)
45
+
46
+ # Move begin up two lines so it captures compilation exceptions.
47
+ begin
48
+ render_source = create_template_source(handler, template, render_symbol, local_assigns.keys)
49
+ line_offset = @@template_args[render_symbol].size + handler.line_offset
50
+
51
+ file_name = 'compiled-template' if file_name.blank?
52
+ CompiledTemplates.module_eval(render_source, file_name, -line_offset)
53
+ rescue Exception => e # errors from template code
54
+ if logger
55
+ logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
56
+ logger.debug "Function body: #{render_source}"
57
+ logger.debug "Backtrace: #{e.backtrace.join("\n")}"
58
+ end
59
+
60
+ # There's no way to tell Haml about the filename,
61
+ # so we've got to insert it ourselves.
62
+ e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error)
63
+
64
+ raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e)
65
+ end
66
+
67
+ @@compile_time[render_symbol] = Time.now
68
+ # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger
69
+ end
70
+ end
71
+ end
72
+ # :startdoc:
@@ -0,0 +1,863 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
3
+
4
+ # = Sass (Syntactically Awesome StyleSheets)
5
+ #
6
+ # Sass is a meta-language on top of CSS
7
+ # that's used to describe the style of a document
8
+ # cleanly and structurally,
9
+ # with more power than flat CSS allows.
10
+ # Sass both provides a simpler, more elegant syntax for CSS
11
+ # and implements various features that are useful
12
+ # for creating manageable stylesheets.
13
+ #
14
+ # == Features
15
+ #
16
+ # * Whitespace active
17
+ # * Well-formatted output
18
+ # * Elegant input
19
+ # * Feature-rich
20
+ #
21
+ # == Using Sass
22
+ #
23
+ # Sass can be used in three ways:
24
+ # as a plugin for Ruby on Rails,
25
+ # as a standalone Ruby module,
26
+ # and as a command-line tool.
27
+ # Sass is bundled with Haml,
28
+ # so if the Haml plugin or RubyGem is installed,
29
+ # Sass will already be installed as a plugin or gem, respectively.
30
+ # The first step for all of these is to install the Haml gem:
31
+ #
32
+ # gem install haml
33
+ #
34
+ # To enable it as a Rails plugin,
35
+ # then run
36
+ #
37
+ # haml --rails path/to/rails/app
38
+ #
39
+ # To enable Sass in Merb,
40
+ # add
41
+ #
42
+ # dependency "merb-haml"
43
+ #
44
+ # to config/dependencies.rb.
45
+ #
46
+ # Sass templates in Rails don't quite function in the same way as views,
47
+ # because they don't contain dynamic content,
48
+ # and so only need to be compiled when the template file has been updated.
49
+ # By default (see options, below),
50
+ # ".sass" files are placed in public/stylesheets/sass.
51
+ # Then, whenever necessary, they're compiled into corresponding CSS files in public/stylesheets.
52
+ # For instance, public/stylesheets/sass/main.sass would be compiled to public/stylesheets/main.css.
53
+ #
54
+ # To run Sass from the commandline, just use
55
+ #
56
+ # sass input.sass output.css
57
+ #
58
+ # Use <tt>sass --help</tt> for full documentation.
59
+ #
60
+ # Using Sass in Ruby code is very simple.
61
+ # After installing the Haml gem,
62
+ # you can use it by running <tt>require "sass"</tt>
63
+ # and using Sass::Engine like so:
64
+ #
65
+ # engine = Sass::Engine.new("#main\n :background-color #0000ff")
66
+ # engine.render #=> "#main { background-color: #0000ff; }\n"
67
+ #
68
+ # == CSS Rules
69
+ #
70
+ # Rules in flat CSS have two elements:
71
+ # the selector
72
+ # (e.g. "#main", "div p", "li a:hover")
73
+ # and the attributes
74
+ # (e.g. "color: #00ff00;", "width: 5em;").
75
+ #
76
+ # Sass has both of these,
77
+ # as well as one additional element: nested rules.
78
+ #
79
+ # === Rules and Selectors
80
+ #
81
+ # However, some of the syntax is a little different.
82
+ # The syntax for selectors is the same,
83
+ # but instead of using brackets to delineate the attributes that belong to a particular rule,
84
+ # Sass uses two spaces of indentation.
85
+ # For example:
86
+ #
87
+ # #main p
88
+ # <attribute>
89
+ # <attribute>
90
+ # ...
91
+ #
92
+ # Like CSS, you can stretch rules over multiple lines.
93
+ # However, unlike CSS, you can only do this if each line but the last
94
+ # ends with a comma.
95
+ # For example:
96
+ #
97
+ # .users #userTab,
98
+ # .posts #postsTab
99
+ # <attributes>
100
+ #
101
+ # === Attributes
102
+ #
103
+ # There are two different ways to write CSS attrbibutes.
104
+ # The first is very similar to the how you're used to writing them:
105
+ # with a colon between the name and the value.
106
+ # However, Sass attributes don't have semicolons at the end;
107
+ # each attribute is on its own line, so they aren't necessary.
108
+ # For example:
109
+ #
110
+ # #main p
111
+ # color: #00ff00
112
+ # width: 97%
113
+ #
114
+ # is compiled to:
115
+ #
116
+ # #main p {
117
+ # color: #00ff00;
118
+ # width: 97% }
119
+ #
120
+ # The second syntax for attributes is slightly different.
121
+ # The colon is at the beginning of the attribute,
122
+ # rather than between the name and the value,
123
+ # so it's easier to tell what elements are attributes just by glancing at them.
124
+ # For example:
125
+ #
126
+ # #main p
127
+ # :color #00ff00
128
+ # :width 97%
129
+ #
130
+ # is compiled to:
131
+ #
132
+ # #main p {
133
+ # color: #00ff00;
134
+ # width: 97% }
135
+ #
136
+ # By default, either attribute syntax may be used.
137
+ # If you want to force one or the other,
138
+ # see the <tt>:attribute_syntax</tt> option below.
139
+ #
140
+ # === Nested Rules
141
+ #
142
+ # Rules can also be nested within each other.
143
+ # This signifies that the inner rule's selector is a child of the outer selector.
144
+ # For example:
145
+ #
146
+ # #main p
147
+ # :color #00ff00
148
+ # :width 97%
149
+ #
150
+ # .redbox
151
+ # :background-color #ff0000
152
+ # :color #000000
153
+ #
154
+ # is compiled to:
155
+ #
156
+ # #main p {
157
+ # color: #00ff00;
158
+ # width: 97%; }
159
+ # #main p .redbox {
160
+ # background-color: #ff0000;
161
+ # color: #000000; }
162
+ #
163
+ # This makes insanely complicated CSS layouts with lots of nested selectors very simple:
164
+ #
165
+ # #main
166
+ # :width 97%
167
+ #
168
+ # p, div
169
+ # :font-size 2em
170
+ # a
171
+ # :font-weight bold
172
+ #
173
+ # pre
174
+ # :font-size 3em
175
+ #
176
+ # is compiled to:
177
+ #
178
+ # #main {
179
+ # width: 97%; }
180
+ # #main p, #main div {
181
+ # font-size: 2em; }
182
+ # #main p a, #main div a {
183
+ # font-weight: bold; }
184
+ # #main pre {
185
+ # font-size: 3em; }
186
+ #
187
+ # === Referencing Parent Rules
188
+ #
189
+ # In addition to the default behavior of inserting the parent selector
190
+ # as a CSS parent of the current selector
191
+ # (e.g. above, "#main" is the parent of "p"),
192
+ # you can have more fine-grained control over what's done with the parent selector
193
+ # by using the ampersand character "&" in your selectors.
194
+ #
195
+ # The ampersand is automatically replaced by the parent selector,
196
+ # instead of having it prepended.
197
+ # This allows you to cleanly create pseudo-attributes:
198
+ #
199
+ # a
200
+ # :font-weight bold
201
+ # :text-decoration none
202
+ # &:hover
203
+ # :text-decoration underline
204
+ # &:visited
205
+ # :font-weight normal
206
+ #
207
+ # Which would become:
208
+ #
209
+ # a {
210
+ # font-weight: bold;
211
+ # text-decoration: none; }
212
+ # a:hover {
213
+ # text-decoration: underline; }
214
+ # a:visited {
215
+ # font-weight: normal; }
216
+ #
217
+ # It also allows you to add selectors at the base of the hierarchy,
218
+ # which can be useuful for targeting certain styles to certain browsers:
219
+ #
220
+ # #main
221
+ # :width 90%
222
+ # #sidebar
223
+ # :float left
224
+ # :margin-left 20%
225
+ # .ie6 &
226
+ # :margin-left 40%
227
+ #
228
+ # Which would become:
229
+ #
230
+ # #main {
231
+ # width: 90%; }
232
+ # #main #sidebar {
233
+ # float: left;
234
+ # margin-left: 20%; }
235
+ # .ie6 #main #sidebar {
236
+ # margin-left: 40%; }
237
+ #
238
+ # === Attribute Namespaces
239
+ #
240
+ # CSS has quite a few attributes that are in "namespaces;"
241
+ # for instance, "font-family," "font-size," and "font-weight"
242
+ # are all in the "font" namespace.
243
+ # In CSS, if you want to set a bunch of attributes in the same namespace,
244
+ # you have to type it out each time.
245
+ # Sass offers a shortcut for this:
246
+ # just write the namespace one,
247
+ # then indent each of the sub-attributes within it.
248
+ # For example:
249
+ #
250
+ # .funky
251
+ # :font
252
+ # :family fantasy
253
+ # :size 30em
254
+ # :weight bold
255
+ #
256
+ # is compiled to:
257
+ #
258
+ # .funky {
259
+ # font-family: fantasy;
260
+ # font-size: 30em;
261
+ # font-weight: bold; }
262
+ #
263
+ # === Rule Escaping
264
+ #
265
+ # In case, for whatever reason, you need to write a rule
266
+ # that begins with a Sass-meaningful character,
267
+ # you can escape it with a backslash (<tt>\</tt>).
268
+ # For example:
269
+ #
270
+ # #main
271
+ # \+div
272
+ # clear: both
273
+ #
274
+ # is compiled to:
275
+ #
276
+ # #main +div {
277
+ # clear: both; }
278
+ #
279
+ # == Constants
280
+ #
281
+ # Sass has support for setting document-wide constants.
282
+ # They're set using an exclamation mark followed by the name,
283
+ # an equals sign, and the value.
284
+ # An attribute can then be set to the value of a constant
285
+ # by following it with another equals sign.
286
+ # For example:
287
+ #
288
+ # !main_color = #00ff00
289
+ #
290
+ # #main
291
+ # :color = !main_color
292
+ # :p
293
+ # :background-color = !main_color
294
+ # :color #000000
295
+ #
296
+ # is compiled to:
297
+ #
298
+ # #main {
299
+ # color: #00ff00; }
300
+ # #main p {
301
+ # background-color: #00ff00;
302
+ # color: #000000; }
303
+ #
304
+ # === Arithmetic
305
+ #
306
+ # You can even do basic arithmetic with constants.
307
+ # Sass recognizes numbers, colors,
308
+ # lengths (numbers with units),
309
+ # and strings (everything that's not one of the above),
310
+ # and various operators that work on various values.
311
+ # All the normal arithmetic operators
312
+ # (+, -, *, /, %, and parentheses for grouping)
313
+ # are defined as usual
314
+ # for numbers, colors, and lengths.
315
+ # The "+" operator is also defined for Strings
316
+ # as the concatenation operator.
317
+ # For example:
318
+ #
319
+ # !main_width = 10
320
+ # !unit1 = em
321
+ # !unit2 = px
322
+ # !bg_color = #a5f39e
323
+ #
324
+ # #main
325
+ # :background-color = !bg_color
326
+ # p
327
+ # :background-color = !bg_color + #202020
328
+ # :width = !main_width + !unit1
329
+ # img.thumb
330
+ # :width = (!main_width + 15) + !unit2
331
+ #
332
+ # is compiled to:
333
+ #
334
+ # #main {
335
+ # background-color: #a5f39e; }
336
+ # #main p {
337
+ # background-color: #c5ffbe;
338
+ # width: 10em; }
339
+ # #main img.thumb {
340
+ # width: 25em; }
341
+ #
342
+ # === Colors
343
+ #
344
+ # Colors may be written as three- or six-digit hex numbers prefixed
345
+ # by a pound sign (#), or as HTML4 color names. For example,
346
+ # "#ff0", "#ffff00" and "yellow" all refer to the same color.
347
+ #
348
+ # Not only can arithmetic be done between colors and other colors,
349
+ # but it can be done between colors and normal numbers.
350
+ # In this case, the operation is done piecewise one each of the
351
+ # Red, Green, and Blue components of the color.
352
+ # For example:
353
+ #
354
+ # !main_color = #a5f39e
355
+ #
356
+ # #main
357
+ # :background-color = !main_color
358
+ # p
359
+ # :background-color = !main_color + 32
360
+ #
361
+ # is compiled to:
362
+ #
363
+ # #main {
364
+ # background-color: #a5f39e; }
365
+ # #main p {
366
+ # background-color: #c5ffbe; }
367
+ #
368
+ # === Strings
369
+ #
370
+ # Strings are the type that's used by default
371
+ # when an element in a bit of constant arithmetic isn't recognized
372
+ # as another type of constant.
373
+ # However, they can also be created explicitly be wrapping a section of code with quotation marks.
374
+ # Inside the quotation marks,
375
+ # a backslash can be used to
376
+ # escape quotation marks that you want to appear in the CSS.
377
+ # For example:
378
+ #
379
+ # !content = "Hello, \"Hubert\" Bean."
380
+ #
381
+ # #main
382
+ # :content = "string(" + !content + ")"
383
+ #
384
+ # is compiled to:
385
+ #
386
+ # #main {
387
+ # content: string(Hello, "Hubert" Bean.) }
388
+ #
389
+ # === Optional Assignment
390
+ #
391
+ # You can assign Sass constants if they aren't already assigned
392
+ # using the ||= assignment operator.
393
+ # This means that if the constant has already been assigned to,
394
+ # it won't be re-assigned,
395
+ # but if it doesn't have a value yet,
396
+ # it will be given one.
397
+ # For example:
398
+ #
399
+ # !content = "First content"
400
+ # !content ||= "Second content?"
401
+ #
402
+ # #main
403
+ # content = content
404
+ #
405
+ # is compiled to:
406
+ #
407
+ # #main {
408
+ # content: First content; }
409
+ #
410
+ # However,
411
+ #
412
+ # !content ||= "Second content?"
413
+ #
414
+ # #main
415
+ # content = content
416
+ #
417
+ # is compiled to:
418
+ #
419
+ # #main {
420
+ # content: Second content?; }
421
+ #
422
+ # === Default Concatenation
423
+ #
424
+ # All those plusses and quotes for concatenating strings
425
+ # can get pretty messy, though.
426
+ # Most of the time, if you want to concatenate stuff,
427
+ # you just want individual values with spaces in between them.
428
+ # Thus, in Sass, when two values are next to each other without an operator,
429
+ # they're simply joined with a space.
430
+ # For example:
431
+ #
432
+ # !font_family = "sans-serif"
433
+ # !main_font_size = 1em
434
+ #
435
+ # #main
436
+ # :font
437
+ # :family = !font_family
438
+ # :size = !main_font_size
439
+ # h6
440
+ # :font = italic "small-caps" bold (!main_font_size + 0.1em) !font_family
441
+ #
442
+ # is compiled to:
443
+ #
444
+ # #main {
445
+ # font-family: sans-serif;
446
+ # font-size: 1em; }
447
+ # #main h6 {
448
+ # font: italic small-caps bold 1.1em sans-serif; }
449
+ #
450
+ # == Directives
451
+ #
452
+ # Directives allow the author to directly issue instructions to the Sass compiler.
453
+ # They're prefixed with an at sign, "<tt>@</tt>",
454
+ # followed by the name of the directive,
455
+ # a space, and any arguments to it -
456
+ # just like CSS directives.
457
+ # For example:
458
+ #
459
+ # @import red.sass
460
+ #
461
+ # === Import
462
+ #
463
+ # Currently, the only directive is the "import" directive.
464
+ # It works in a very similar way to the CSS import directive,
465
+ # and sometimes compiles to a literal CSS "@import".
466
+ #
467
+ # Sass can import either other Sass files or plain CSS files.
468
+ # If it imports a Sass file,
469
+ # not only are the rules from that file included,
470
+ # but all constants in that file are made available in the current file.
471
+ #
472
+ # Sass looks for other Sass files in the working directory,
473
+ # and the Sass file directory under Rails or Merb.
474
+ # Additional search directories may be specified
475
+ # using the :load_paths option (see below).
476
+ #
477
+ # Sass can also import plain CSS files.
478
+ # In this case, it doesn't literally include the content of the files;
479
+ # rather, it uses the built-in CSS "@import" directive to tell the client program
480
+ # to import the files.
481
+ #
482
+ # The import directive can take either a full filename
483
+ # or a filename without an extension.
484
+ # If an extension isn't provided,
485
+ # Sass will try to find a Sass file with the given basename in the load paths,
486
+ # and, failing that, will assume a relevant CSS file will be available.
487
+ #
488
+ # For example,
489
+ #
490
+ # @import foo.sass
491
+ #
492
+ # would compile to
493
+ #
494
+ # .foo
495
+ # :color #f00
496
+ #
497
+ # whereas
498
+ #
499
+ # @import foo.css
500
+ #
501
+ # would compile to
502
+ #
503
+ # @import foo.css
504
+ #
505
+ # Finally,
506
+ #
507
+ # @import foo
508
+ #
509
+ # might compile to either,
510
+ # depending on whether a file called "foo.sass" existed.
511
+ #
512
+ # === @font-face, @media, etc.
513
+ #
514
+ # Sass behaves as you'd expect for normal CSS @-directives.
515
+ # For example:
516
+ #
517
+ # @font-face
518
+ # font-family: "Bitstream Vera Sans"
519
+ # src: url(http://foo.bar/bvs")
520
+ #
521
+ # compiles to:
522
+ #
523
+ # @font-face {
524
+ # font-family: "Bitstream Vera Sans";
525
+ # src: url(http://foo.bar/bvs"); }
526
+ #
527
+ # and
528
+ #
529
+ # @media print
530
+ # #sidebar
531
+ # display: none
532
+ #
533
+ # #main
534
+ # background-color: white
535
+ #
536
+ # compiles to:
537
+ #
538
+ # @media print {
539
+ # #sidebar {
540
+ # display: none; }
541
+ #
542
+ # #main {
543
+ # background-color: white; }
544
+ # }
545
+ #
546
+ # == Comments
547
+ #
548
+ # === Silent Comments
549
+ #
550
+ # It's simple to add "silent" comments,
551
+ # which don't output anything to the CSS document,
552
+ # to a Sass document.
553
+ # Simply use the familiar C-style notation for a one-line comment, "//",
554
+ # at the normal indentation level and all text following it won't be output.
555
+ # For example:
556
+ #
557
+ # // A very awesome rule.
558
+ # #awesome.rule
559
+ # // An equally awesome attribute.
560
+ # :awesomeness very
561
+ #
562
+ # becomes
563
+ #
564
+ # #awesome.rule {
565
+ # awesomeness: very; }
566
+ #
567
+ # You can also nest text beneath a comment to comment out a whole block.
568
+ # For example:
569
+ #
570
+ # // A very awesome rule
571
+ # #awesome.rule
572
+ # // Don't use these attributes
573
+ # color: green
574
+ # font-size: 10em
575
+ # color: red
576
+ #
577
+ # becomes
578
+ #
579
+ # #awesome.rule {
580
+ # color: red; }
581
+ #
582
+ # === Loud Comments
583
+ #
584
+ # "Loud" comments are just as easy as silent ones.
585
+ # These comments output to the document as CSS comments,
586
+ # and thus use the same opening sequence: "/*".
587
+ # For example:
588
+ #
589
+ # /* A very awesome rule.
590
+ # #awesome.rule
591
+ # /* An equally awesome attribute.
592
+ # :awesomeness very
593
+ #
594
+ # becomes
595
+ #
596
+ # /* A very awesome rule. */
597
+ # #awesome.rule {
598
+ # /* An equally awesome attribute. */
599
+ # awesomeness: very; }
600
+ #
601
+ # You can also nest content beneath loud comments. For example:
602
+ #
603
+ # #pbj
604
+ # /* This rule describes
605
+ # the styling of the element
606
+ # that represents
607
+ # a peanut butter and jelly sandwich.
608
+ # :background-image url(/images/pbj.png)
609
+ # :color red
610
+ #
611
+ # becomes
612
+ #
613
+ # #pbj {
614
+ # /* This rule describes
615
+ # * the styling of the element
616
+ # * that represents
617
+ # * a peanut butter and jelly sandwich. */
618
+ # background-image: url(/images/pbj.png);
619
+ # color: red; }
620
+ #
621
+ # == Mixins
622
+ #
623
+ # Mixins enable you to define groups of CSS attributes and
624
+ # then include them inline in any number of selectors
625
+ # throughout the document.
626
+ #
627
+ # === Defining a Mixin
628
+ #
629
+ # To define a mixin you use a slightly modified form of selector syntax.
630
+ # For example the 'large-text' mixin is defined as follows:
631
+ #
632
+ # =large-text
633
+ # :font
634
+ # :family Arial
635
+ # :size 20px
636
+ # :weight bold
637
+ # :color #ff0000
638
+ #
639
+ # The initial '=' marks this as a mixin rather than a standard selector.
640
+ # The CSS rules that follow won't be included until the mixin is referenced later on.
641
+ # Anything you can put into a standard selector,
642
+ # you can put into a mixin definition. e.g.
643
+ #
644
+ # =clearfix
645
+ # display: inline-block
646
+ # &:after
647
+ # content: "."
648
+ # display: block
649
+ # height: 0
650
+ # clear: both
651
+ # visibility: hidden
652
+ # * html &
653
+ # height: 1px
654
+ #
655
+ #
656
+ # === Mixing it in
657
+ #
658
+ # Inlining a defined mixin is simple,
659
+ # just prepend a '+' symbol to the name of a mixin defined earlier in the document.
660
+ # So to inline the 'large-text' defined earlier,
661
+ # we include the statment '+large-text' in our selector definition thus:
662
+ #
663
+ # .page-title
664
+ # +large-text
665
+ # :padding 4px
666
+ # :margin
667
+ # :top 10px
668
+ #
669
+ #
670
+ # This will produce the following CSS output:
671
+ #
672
+ # .page-title {
673
+ # font-family: Arial;
674
+ # font-size: 20px;
675
+ # font-weight: bold;
676
+ # color: #ff0000;
677
+ # padding: 4px;
678
+ # margin-top: 10px;
679
+ # }
680
+ #
681
+ # Any number of mixins may be defined and there is no limit on
682
+ # the number that can be included in a particular selector.
683
+ #
684
+ # Mixin definitions can also include references to other mixins defined earlier in the file.
685
+ # E.g.
686
+ #
687
+ # =highlighted-background
688
+ # background:
689
+ # color: #fc0
690
+ # =header-text
691
+ # font:
692
+ # size: 20px
693
+ #
694
+ # =compound
695
+ # +highlighted-background
696
+ # +header-text
697
+ #
698
+ #
699
+ # == Output Style
700
+ #
701
+ # Although the default CSS style that Sass outputs is very nice,
702
+ # and reflects the structure of the document in a similar way that Sass does,
703
+ # sometimes it's good to have other formats available.
704
+ #
705
+ # Sass allows you to choose between three different output styles
706
+ # by setting the <tt>:style</tt> option.
707
+ # In Rails, this is done by setting <tt>Sass::Plugin.options[:style]</tt>;
708
+ # outside Rails, it's done by passing an options hash with </tt>:style</tt> set.
709
+ #
710
+ # === <tt>:nested</tt>
711
+ #
712
+ # Nested style is the default Sass style,
713
+ # because it reflects the structure of the document
714
+ # in much the same way Sass does.
715
+ # Each attribute has its own line,
716
+ # but the indentation isn't constant.
717
+ # Each rule is indented based on how deeply it's nested.
718
+ # For example:
719
+ #
720
+ # #main {
721
+ # color: #fff;
722
+ # background-color: #000; }
723
+ # #main p {
724
+ # width: 10em; }
725
+ #
726
+ # .huge {
727
+ # font-size: 10em;
728
+ # font-weight: bold;
729
+ # text-decoration: underline; }
730
+ #
731
+ # Nested style is very useful when looking at large CSS files
732
+ # for the same reason Sass is useful for making them:
733
+ # it allows you to very easily grasp the structure of the file
734
+ # without actually reading anything.
735
+ #
736
+ # === <tt>:expanded</tt>
737
+ #
738
+ # Expanded is the typical human-made CSS style,
739
+ # with each attribute and rule taking up one line.
740
+ # Attributes are indented within the rules,
741
+ # but the rules aren't indented in any special way.
742
+ # For example:
743
+ #
744
+ # #main {
745
+ # color: #fff;
746
+ # background-color: #000;
747
+ # }
748
+ # #main p {
749
+ # width: 10em;
750
+ # }
751
+ #
752
+ # .huge {
753
+ # font-size: 10em;
754
+ # font-weight: bold;
755
+ # text-decoration: underline;
756
+ # }
757
+ #
758
+ # === <tt>:compact</tt>
759
+ #
760
+ # Compact style, as the name would imply,
761
+ # takes up less space than Nested or Expanded.
762
+ # However, it's also harder to read.
763
+ # Each CSS rule takes up only one line,
764
+ # with every attribute defined on that line.
765
+ # Nested rules are placed next to each other with no newline,
766
+ # while groups of rules have newlines between them.
767
+ # For example:
768
+ #
769
+ # #main { color: #fff; background-color: #000; }
770
+ # #main p { width: 10em; }
771
+ #
772
+ # .huge { font-size: 10em; font-weight: bold; text-decoration: underline; }
773
+ #
774
+ # === <tt>:compressed</tt>
775
+ #
776
+ # Compressed style takes up the minimum amount of space possible,
777
+ # having no whitespace except that necessary to separate selectors
778
+ # and a newline at the end of the file.
779
+ # It's not meant to be human-readable.
780
+ # For example:
781
+ #
782
+ # #main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
783
+ #
784
+ # == Sass Options
785
+ #
786
+ # Options can be set by setting the <tt>Sass::Plugin.options</tt> hash
787
+ # in <tt>environment.rb</tt> in Rails...
788
+ #
789
+ # Sass::Plugin.options[:style] = :compact
790
+ #
791
+ # ...or by setting the <tt>Merb::Plugin.config[:sass]</tt> hash in <tt>init.rb</tt> in Merb...
792
+ #
793
+ # Merb::Plugin.config[:sass][:style] = :compact
794
+ #
795
+ # ...or by passing an options hash to Sass::Engine.new.
796
+ # Available options are:
797
+ #
798
+ # [<tt>:style</tt>] Sets the style of the CSS output.
799
+ # See the section on Output Style, above.
800
+ #
801
+ # [<tt>:attribute_syntax</tt>] Forces the document to use one syntax for attributes.
802
+ # If the correct syntax isn't used, an error is thrown.
803
+ # <tt>:normal</tt> forces the use of a colon
804
+ # before the attribute name.
805
+ # For example: <tt>:color #0f3</tt>
806
+ # or <tt>:width = !main_width</tt>.
807
+ # <tt>:alternate</tt> forces the use of a colon or equals sign
808
+ # after the attribute name.
809
+ # For example: <tt>color: #0f3</tt>
810
+ # or <tt>width = !main_width</tt>.
811
+ # By default, either syntax is valid.
812
+ #
813
+ # [<tt>:never_update</tt>] Whether the CSS files should never be updated,
814
+ # even if the template file changes.
815
+ # Setting this to true may give small performance gains.
816
+ # It always defaults to false.
817
+ # Only has meaning within Ruby on Rails or Merb.
818
+ #
819
+ # [<tt>:always_update</tt>] Whether the CSS files should be updated every
820
+ # time a controller is accessed,
821
+ # as opposed to only when the template has been modified.
822
+ # Defaults to false.
823
+ # Only has meaning within Ruby on Rails or Merb.
824
+ #
825
+ # [<tt>:always_check</tt>] Whether a Sass template should be checked for updates every
826
+ # time a controller is accessed,
827
+ # as opposed to only when the Rails server starts.
828
+ # If a Sass template has been updated,
829
+ # it will be recompiled and will overwrite the corresponding CSS file.
830
+ # Defaults to false in production mode, true otherwise.
831
+ # Only has meaning within Ruby on Rails or Merb.
832
+ #
833
+ # [<tt>:full_exception</tt>] Whether an error in the Sass code
834
+ # should cause Sass to provide a detailed description.
835
+ # If set to true, the specific error will be displayed
836
+ # along with a line number and source snippet.
837
+ # Otherwise, a simple uninformative error message will be displayed.
838
+ # Defaults to false in production mode, true otherwise.
839
+ # Only has meaning within Ruby on Rails or Merb.
840
+ #
841
+ # [<tt>:template_location</tt>] The directory where Sass templates should be read from.
842
+ # Defaults to <tt>RAILS_ROOT + "/public/stylesheets/sass"</tt>
843
+ # or <tt>MERB_ROOT + "/public/stylesheets/sass"</tt>.
844
+ # Only has meaning within Ruby on Rails or Merb.
845
+ #
846
+ # [<tt>:css_location</tt>] The directory where CSS output should be written to.
847
+ # Defaults to <tt>RAILS_ROOT + "/public/stylesheets"</tt>
848
+ # or <tt>MERB_ROOT + "/public/stylesheets"</tt>.
849
+ # Only has meaning within Ruby on Rails or Merb.
850
+ #
851
+ # [<tt>:filename</tt>] The filename of the file being rendered.
852
+ # This is used solely for reporting errors,
853
+ # and is automatically set when using Rails or Merb.
854
+ #
855
+ # [<tt>:load_paths</tt>] An array of filesystem paths which should be searched
856
+ # for Sass templates imported with the "@import" directive.
857
+ # This defaults to the working directory and, in Rails or Merb,
858
+ # whatever <tt>:template_location</tt> is.
859
+ #
860
+ module Sass; end
861
+
862
+ require 'sass/engine'
863
+ require 'sass/plugin' if defined?(Merb::Plugins)