Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Vendor haml

  • Loading branch information...
commit e356f4f7667c8b20d5e12ad92ae600ceb5197dd8 1 parent aad7956
@holman authored
Showing with 16,395 additions and 0 deletions.
  1. +4 −0 roflclicks.rb
  2. +5 −0 vendor/haml-2.2.1/.yardopts
  3. +20 −0 vendor/haml-2.2.1/MIT-LICENSE
  4. +347 −0 vendor/haml-2.2.1/README.md
  5. +1 −0  vendor/haml-2.2.1/REVISION
  6. +290 −0 vendor/haml-2.2.1/Rakefile
  7. +1 −0  vendor/haml-2.2.1/VERSION
  8. +1 −0  vendor/haml-2.2.1/VERSION_NAME
  9. +7 −0 vendor/haml-2.2.1/bin/css2sass
  10. +9 −0 vendor/haml-2.2.1/bin/haml
  11. +7 −0 vendor/haml-2.2.1/bin/html2haml
  12. +8 −0 vendor/haml-2.2.1/bin/sass
  13. +650 −0 vendor/haml-2.2.1/extra/haml-mode.el
  14. +201 −0 vendor/haml-2.2.1/extra/sass-mode.el
  15. +13 −0 vendor/haml-2.2.1/extra/update_watch.rb
  16. +8 −0 vendor/haml-2.2.1/init.rb
  17. +40 −0 vendor/haml-2.2.1/lib/haml.rb
  18. +302 −0 vendor/haml-2.2.1/lib/haml/buffer.rb
  19. +297 −0 vendor/haml-2.2.1/lib/haml/engine.rb
  20. +22 −0 vendor/haml-2.2.1/lib/haml/error.rb
  21. +459 −0 vendor/haml-2.2.1/lib/haml/exec.rb
  22. +341 −0 vendor/haml-2.2.1/lib/haml/filters.rb
  23. +545 −0 vendor/haml-2.2.1/lib/haml/helpers.rb
  24. +40 −0 vendor/haml-2.2.1/lib/haml/helpers/action_view_extensions.rb
  25. +174 −0 vendor/haml-2.2.1/lib/haml/helpers/action_view_mods.rb
  26. +238 −0 vendor/haml-2.2.1/lib/haml/html.rb
  27. +994 −0 vendor/haml-2.2.1/lib/haml/precompiler.rb
  28. +78 −0 vendor/haml-2.2.1/lib/haml/shared.rb
  29. +51 −0 vendor/haml-2.2.1/lib/haml/template.rb
  30. +58 −0 vendor/haml-2.2.1/lib/haml/template/patch.rb
  31. +71 −0 vendor/haml-2.2.1/lib/haml/template/plugin.rb
  32. +228 −0 vendor/haml-2.2.1/lib/haml/util.rb
  33. +64 −0 vendor/haml-2.2.1/lib/haml/version.rb
  34. +24 −0 vendor/haml-2.2.1/lib/sass.rb
  35. +402 −0 vendor/haml-2.2.1/lib/sass/css.rb
  36. +476 −0 vendor/haml-2.2.1/lib/sass/engine.rb
  37. +79 −0 vendor/haml-2.2.1/lib/sass/environment.rb
  38. +57 −0 vendor/haml-2.2.1/lib/sass/error.rb
  39. +139 −0 vendor/haml-2.2.1/lib/sass/files.rb
  40. +212 −0 vendor/haml-2.2.1/lib/sass/plugin.rb
  41. +57 −0 vendor/haml-2.2.1/lib/sass/plugin/merb.rb
  42. +23 −0 vendor/haml-2.2.1/lib/sass/plugin/rails.rb
  43. +58 −0 vendor/haml-2.2.1/lib/sass/repl.rb
  44. +59 −0 vendor/haml-2.2.1/lib/sass/script.rb
  45. +17 −0 vendor/haml-2.2.1/lib/sass/script/bool.rb
  46. +183 −0 vendor/haml-2.2.1/lib/sass/script/color.rb
  47. +50 −0 vendor/haml-2.2.1/lib/sass/script/funcall.rb
  48. +198 −0 vendor/haml-2.2.1/lib/sass/script/functions.rb
  49. +190 −0 vendor/haml-2.2.1/lib/sass/script/lexer.rb
  50. +177 −0 vendor/haml-2.2.1/lib/sass/script/literal.rb
  51. +14 −0 vendor/haml-2.2.1/lib/sass/script/node.rb
  52. +381 −0 vendor/haml-2.2.1/lib/sass/script/number.rb
  53. +45 −0 vendor/haml-2.2.1/lib/sass/script/operation.rb
  54. +172 −0 vendor/haml-2.2.1/lib/sass/script/parser.rb
  55. +12 −0 vendor/haml-2.2.1/lib/sass/script/string.rb
  56. +34 −0 vendor/haml-2.2.1/lib/sass/script/unary_operation.rb
  57. +31 −0 vendor/haml-2.2.1/lib/sass/script/variable.rb
  58. +84 −0 vendor/haml-2.2.1/lib/sass/tree/comment_node.rb
  59. +30 −0 vendor/haml-2.2.1/lib/sass/tree/debug_node.rb
  60. +68 −0 vendor/haml-2.2.1/lib/sass/tree/directive_node.rb
  61. +48 −0 vendor/haml-2.2.1/lib/sass/tree/for_node.rb
  62. +54 −0 vendor/haml-2.2.1/lib/sass/tree/if_node.rb
  63. +65 −0 vendor/haml-2.2.1/lib/sass/tree/import_node.rb
  64. +29 −0 vendor/haml-2.2.1/lib/sass/tree/mixin_def_node.rb
  65. +48 −0 vendor/haml-2.2.1/lib/sass/tree/mixin_node.rb
  66. +249 −0 vendor/haml-2.2.1/lib/sass/tree/node.rb
  67. +109 −0 vendor/haml-2.2.1/lib/sass/tree/prop_node.rb
  68. +220 −0 vendor/haml-2.2.1/lib/sass/tree/rule_node.rb
  69. +34 −0 vendor/haml-2.2.1/lib/sass/tree/variable_node.rb
  70. +31 −0 vendor/haml-2.2.1/lib/sass/tree/while_node.rb
  71. +1 −0  vendor/haml-2.2.1/rails/init.rb
  72. +99 −0 vendor/haml-2.2.1/test/benchmark.rb
  73. +1,029 −0 vendor/haml-2.2.1/test/haml/engine_test.rb
  74. +254 −0 vendor/haml-2.2.1/test/haml/helper_test.rb
  75. +108 −0 vendor/haml-2.2.1/test/haml/html2haml_test.rb
  76. +52 −0 vendor/haml-2.2.1/test/haml/markaby/standard.mab
  77. +6 −0 vendor/haml-2.2.1/test/haml/mocks/article.rb
  78. +12 −0 vendor/haml-2.2.1/test/haml/results/content_for_layout.xhtml
  79. +9 −0 vendor/haml-2.2.1/test/haml/results/eval_suppressed.xhtml
  80. +62 −0 vendor/haml-2.2.1/test/haml/results/filters.xhtml
  81. +93 −0 vendor/haml-2.2.1/test/haml/results/helpers.xhtml
  82. +10 −0 vendor/haml-2.2.1/test/haml/results/helpful.xhtml
  83. +68 −0 vendor/haml-2.2.1/test/haml/results/just_stuff.xhtml
  84. +12 −0 vendor/haml-2.2.1/test/haml/results/list.xhtml
  85. +40 −0 vendor/haml-2.2.1/test/haml/results/nuke_inner_whitespace.xhtml
  86. +148 −0 vendor/haml-2.2.1/test/haml/results/nuke_outer_whitespace.xhtml
  87. +20 −0 vendor/haml-2.2.1/test/haml/results/original_engine.xhtml
  88. +5 −0 vendor/haml-2.2.1/test/haml/results/partial_layout.xhtml
  89. +21 −0 vendor/haml-2.2.1/test/haml/results/partials.xhtml
  90. +3 −0  vendor/haml-2.2.1/test/haml/results/render_layout.xhtml
  91. +74 −0 vendor/haml-2.2.1/test/haml/results/silent_script.xhtml
  92. +162 −0 vendor/haml-2.2.1/test/haml/results/standard.xhtml
  93. +23 −0 vendor/haml-2.2.1/test/haml/results/tag_parsing.xhtml
  94. +5 −0 vendor/haml-2.2.1/test/haml/results/very_basic.xhtml
  95. +89 −0 vendor/haml-2.2.1/test/haml/results/whitespace_handling.xhtml
  96. +12 −0 vendor/haml-2.2.1/test/haml/rhtml/_av_partial_1.rhtml
  97. +8 −0 vendor/haml-2.2.1/test/haml/rhtml/_av_partial_2.rhtml
  98. +62 −0 vendor/haml-2.2.1/test/haml/rhtml/action_view.rhtml
  99. +54 −0 vendor/haml-2.2.1/test/haml/rhtml/standard.rhtml
  100. +209 −0 vendor/haml-2.2.1/test/haml/template_test.rb
  101. +9 −0 vendor/haml-2.2.1/test/haml/templates/_av_partial_1.haml
  102. +9 −0 vendor/haml-2.2.1/test/haml/templates/_av_partial_1_ugly.haml
  103. +5 −0 vendor/haml-2.2.1/test/haml/templates/_av_partial_2.haml
  104. +5 −0 vendor/haml-2.2.1/test/haml/templates/_av_partial_2_ugly.haml
  105. +3 −0  vendor/haml-2.2.1/test/haml/templates/_layout.erb
  106. +3 −0  vendor/haml-2.2.1/test/haml/templates/_layout_for_partial.haml
  107. +8 −0 vendor/haml-2.2.1/test/haml/templates/_partial.haml
  108. +3 −0  vendor/haml-2.2.1/test/haml/templates/_text_area.haml
  109. +47 −0 vendor/haml-2.2.1/test/haml/templates/action_view.haml
  110. +47 −0 vendor/haml-2.2.1/test/haml/templates/action_view_ugly.haml
  111. +8 −0 vendor/haml-2.2.1/test/haml/templates/breakage.haml
  112. +8 −0 vendor/haml-2.2.1/test/haml/templates/content_for_layout.haml
  113. +11 −0 vendor/haml-2.2.1/test/haml/templates/eval_suppressed.haml
  114. +66 −0 vendor/haml-2.2.1/test/haml/templates/filters.haml
  115. +95 −0 vendor/haml-2.2.1/test/haml/templates/helpers.haml
  116. +11 −0 vendor/haml-2.2.1/test/haml/templates/helpful.haml
  117. +83 −0 vendor/haml-2.2.1/test/haml/templates/just_stuff.haml
  118. +12 −0 vendor/haml-2.2.1/test/haml/templates/list.haml
  119. +32 −0 vendor/haml-2.2.1/test/haml/templates/nuke_inner_whitespace.haml
  120. +144 −0 vendor/haml-2.2.1/test/haml/templates/nuke_outer_whitespace.haml
  121. +17 −0 vendor/haml-2.2.1/test/haml/templates/original_engine.haml
  122. +3 −0  vendor/haml-2.2.1/test/haml/templates/partial_layout.haml
  123. +1 −0  vendor/haml-2.2.1/test/haml/templates/partialize.haml
  124. +12 −0 vendor/haml-2.2.1/test/haml/templates/partials.haml
  125. +2 −0  vendor/haml-2.2.1/test/haml/templates/render_layout.haml
  126. +40 −0 vendor/haml-2.2.1/test/haml/templates/silent_script.haml
  127. +42 −0 vendor/haml-2.2.1/test/haml/templates/standard.haml
  128. +42 −0 vendor/haml-2.2.1/test/haml/templates/standard_ugly.haml
  129. +21 −0 vendor/haml-2.2.1/test/haml/templates/tag_parsing.haml
  130. +4 −0 vendor/haml-2.2.1/test/haml/templates/very_basic.haml
  131. +87 −0 vendor/haml-2.2.1/test/haml/templates/whitespace_handling.haml
  132. +92 −0 vendor/haml-2.2.1/test/haml/util_test.rb
  133. +12 −0 vendor/haml-2.2.1/test/linked_rails.rb
  134. +238 −0 vendor/haml-2.2.1/test/sass/css2sass_test.rb
  135. +837 −0 vendor/haml-2.2.1/test/sass/engine_test.rb
  136. +125 −0 vendor/haml-2.2.1/test/sass/functions_test.rb
  137. +9 −0 vendor/haml-2.2.1/test/sass/more_results/more1.css
  138. +26 −0 vendor/haml-2.2.1/test/sass/more_results/more1_with_line_comments.css
  139. +29 −0 vendor/haml-2.2.1/test/sass/more_results/more_import.css
  140. +2 −0  vendor/haml-2.2.1/test/sass/more_templates/_more_partial.sass
  141. +23 −0 vendor/haml-2.2.1/test/sass/more_templates/more1.sass
  142. +11 −0 vendor/haml-2.2.1/test/sass/more_templates/more_import.sass
  143. +220 −0 vendor/haml-2.2.1/test/sass/plugin_test.rb
  144. +4 −0 vendor/haml-2.2.1/test/sass/results/alt.css
  145. +9 −0 vendor/haml-2.2.1/test/sass/results/basic.css
  146. +5 −0 vendor/haml-2.2.1/test/sass/results/compact.css
  147. +87 −0 vendor/haml-2.2.1/test/sass/results/complex.css
  148. +1 −0  vendor/haml-2.2.1/test/sass/results/compressed.css
  149. +19 −0 vendor/haml-2.2.1/test/sass/results/expanded.css
  150. +29 −0 vendor/haml-2.2.1/test/sass/results/import.css
  151. +49 −0 vendor/haml-2.2.1/test/sass/results/line_numbers.css
  152. +95 −0 vendor/haml-2.2.1/test/sass/results/mixins.css
  153. +24 −0 vendor/haml-2.2.1/test/sass/results/multiline.css
  154. +22 −0 vendor/haml-2.2.1/test/sass/results/nested.css
  155. +13 −0 vendor/haml-2.2.1/test/sass/results/parent_ref.css
  156. +16 −0 vendor/haml-2.2.1/test/sass/results/script.css
  157. +1 −0  vendor/haml-2.2.1/test/sass/results/subdir/nested_subdir/nested_subdir.css
  158. +3 −0  vendor/haml-2.2.1/test/sass/results/subdir/subdir.css
  159. +11 −0 vendor/haml-2.2.1/test/sass/results/units.css
  160. +276 −0 vendor/haml-2.2.1/test/sass/script_test.rb
  161. +2 −0  vendor/haml-2.2.1/test/sass/templates/_partial.sass
  162. +16 −0 vendor/haml-2.2.1/test/sass/templates/alt.sass
  163. +23 −0 vendor/haml-2.2.1/test/sass/templates/basic.sass
  164. +2 −0  vendor/haml-2.2.1/test/sass/templates/bork.sass
  165. +2 −0  vendor/haml-2.2.1/test/sass/templates/bork2.sass
  166. +17 −0 vendor/haml-2.2.1/test/sass/templates/compact.sass
  167. +309 −0 vendor/haml-2.2.1/test/sass/templates/complex.sass
  168. +15 −0 vendor/haml-2.2.1/test/sass/templates/compressed.sass
  169. +17 −0 vendor/haml-2.2.1/test/sass/templates/expanded.sass
  170. +11 −0 vendor/haml-2.2.1/test/sass/templates/import.sass
  171. +19 −0 vendor/haml-2.2.1/test/sass/templates/importee.sass
  172. +13 −0 vendor/haml-2.2.1/test/sass/templates/line_numbers.sass
  173. +76 −0 vendor/haml-2.2.1/test/sass/templates/mixins.sass
  174. +20 −0 vendor/haml-2.2.1/test/sass/templates/multiline.sass
  175. +25 −0 vendor/haml-2.2.1/test/sass/templates/nested.sass
  176. +25 −0 vendor/haml-2.2.1/test/sass/templates/parent_ref.sass
  177. +101 −0 vendor/haml-2.2.1/test/sass/templates/script.sass
  178. +2 −0  vendor/haml-2.2.1/test/sass/templates/subdir/nested_subdir/_nested_partial.sass
  179. +3 −0  vendor/haml-2.2.1/test/sass/templates/subdir/nested_subdir/nested_subdir.sass
  180. +6 −0 vendor/haml-2.2.1/test/sass/templates/subdir/subdir.sass
  181. +11 −0 vendor/haml-2.2.1/test/sass/templates/units.sass
  182. +29 −0 vendor/haml-2.2.1/test/test_helper.rb
View
4 roflclicks.rb
@@ -3,6 +3,10 @@
require 'haml'
require 'dm-core'
+Dir['vendor/*'].each do |lib|
+ $:.unshift(File.join(File.dirname(__FILE__), lib, 'lib'))
+end
+
@@total_views = Dir.entries("views").size - 3
class Click
View
5 vendor/haml-2.2.1/.yardopts
@@ -0,0 +1,5 @@
+--readme README.md
+--markup markdown
+--markup-provider maruku
+--protected
+--no-highlight
View
20 vendor/haml-2.2.1/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
347 vendor/haml-2.2.1/README.md
@@ -0,0 +1,347 @@
+# Haml and Sass
+
+Haml and Sass are templating engines
+for the two most common types of documents on the web:
+HTML and CSS, respectively.
+They are designed to make it both easier and more pleasant
+to code HTML and CSS documents,
+by eliminating redundancy,
+reflecting the underlying structure that the document represents,
+and providing elegant, easily understandable, and powerful syntax.
+
+## Using
+
+Haml and Sass can be used from the command line
+or as part of a Ruby web framework.
+The first step is to install the gem:
+
+ gem install haml
+
+After you convert some HTML to Haml or some CSS to Sass,
+you can run
+
+ haml document.haml
+ sass style.sass
+
+to compile them.
+For more information on these commands, check out
+
+ haml --help
+ sass --help
+
+To install Haml and Sass as a Rails plugin,
+just run `haml --rails path/to/rails/app`
+and both Haml and Sass will be installed.
+Views with the `.html.haml` extension will automatically use Haml.
+Sass is a little more complicated;
+`.sass` files should be placed in `public/stylesheets/sass`,
+where they'll be automatically compiled
+to corresponding CSS files in `public/stylesheets` when needed
+(the Sass template directory is customizable...
+see [the Sass reference](http://sass-lang.com/docs/yardoc/SASS_REFERENCE.md.html#template_location-option) for details).
+
+For Merb, `.html.haml` views will work without any further modification.
+To enable Sass, you also need to add a dependency.
+To do so, just add
+
+ dependency "merb-haml"
+
+to `config/dependencies.rb` (or `config/init.rb` in a flat/very flat Merb application).
+Then it'll work just like it does in Rails.
+
+To use Haml and Sass programatically,
+check out the [YARD documentation](http://haml-lang.com/docs/yardoc).
+
+## Formatting
+
+### Haml
+
+The most basic element of Haml
+is a shorthand for creating HTML:
+
+ %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents
+
+No end-tag is needed; Haml handles that automatically.
+If you prefer HTML-style attributes, you can also use:
+
+ %tagname(attr1='value1' attr2='value2') Contents
+
+Adding `class` and `id` attributes is even easier.
+Haml uses the same syntax as the CSS that styles the document:
+
+ %tagname#id.class
+
+In fact, when you're using the `<div>` tag,
+it becomes _even easier_.
+Because `<div>` is such a common element,
+a tag without a name defaults to a div. So
+
+ #foo Hello!
+
+becomes
+
+ <div id='foo'>Hello!</div>
+
+Haml uses indentation
+to bring the individual elements to represent the HTML structure.
+A tag's children are indented beneath than the parent tag.
+Again, a closing tag is automatically added.
+For example:
+
+ %ul
+ %li Salt
+ %li Pepper
+
+becomes:
+
+ <ul>
+ <li>Salt</li>
+ <li>Pepper</li>
+ </ul>
+
+You can also put plain text as a child of an element:
+
+ %p
+ Hello,
+ World!
+
+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
+like `if` and `while`:
+
+ %p
+ Date/Time:
+ - now = DateTime.now
+ %strong= now
+ - if now > DateTime.parse("December 31, 2006")
+ = "Happy new " + "year!"
+
+Haml provides far more tools than those presented here.
+Check out the reference documentation in the Haml module.
+
+### Sass
+
+At its most basic,
+Sass is just another way of writing CSS.
+Although it's very much like normal CSS,
+the basic syntax offers a few helpful features:
+indentation indicates the properties in a rule,
+rather than non-DRY brackets;
+and newlines indicate the end of a properties,
+rather than a semicolon.
+For example:
+
+ #main
+ background-color: #f00
+ width: 98%
+
+becomes:
+
+ #main {
+ background-color: #f00;
+ width: 98% }
+
+However, Sass provides much more than a way to make CSS look nice.
+In CSS, it's important to have accurate selectors,
+so your styles don't just apply to everything.
+However, in order to do this,
+you need to use nested element selectors.
+These get very ugly very quickly.
+I'm sure everyone's had to write something like
+"#main .sidebar .top p h1 a",
+followed by
+"#main .sidebar .top p h1 a:visited" and
+"#main .sidebar .top p h1 a:hover".
+Well, Sass gets rid of that.
+Like Haml, it uses indentation to indicate the structure of the document.
+So, what was:
+
+ #main {
+ width: 90%;
+ }
+ #main p {
+ border-style: solid;
+ border-width: 1px;
+ border-color: #00f;
+ }
+ #main p a {
+ text-decoration: none;
+ font-weight: bold;
+ }
+ #main p a:hover {
+ text-decoration: underline;
+ }
+
+becomes:
+
+ #main
+ width: 90%
+ p
+ border-style: solid
+ border-width: 1px
+ border-color: #00f
+ a
+ text-decoration: none
+ font-weight: bold
+ a:hover
+ text-decoration: underline
+
+Pretty nice, no? Well, it gets better.
+One of the main complaints against CSS is that it doesn't allow variables.
+What if have a color or a width you re-use all the time?
+In CSS, you just have to re-type it each time,
+which is a nightmare when you decide to change it later.
+Not so for Sass!
+You can use the `!` character to set variables.
+Then, if you put `=` after your property name,
+you can set it to a variable.
+For example:
+
+ !note_bg= #55aaff
+
+ #main
+ width: 70%
+ .note
+ background-color = !note_bg
+ p
+ width: 5em
+ background-color = !note_bg
+
+becomes:
+
+ #main {
+ width: 70%; }
+ #main .note {
+ background-color: #55aaff; }
+ #main p {
+ width: 5em;
+ background-color: #55aaff; }
+
+You can even do simple arithmetic operations with variables,
+adding numbers and even colors together:
+
+ !main_bg= #46ar12
+ !main_width= 40em
+
+ #main
+ background-color = !main_bg
+ width = !main_width
+ .sidebar
+ background-color = !main_bg + #333333
+ width = !main_width - 25em
+
+becomes:
+
+ #main {
+ background-color: #46a312;
+ width: 40em; }
+ #main .sidebar {
+ background-color: #79d645;
+ width: 15em; }
+
+Taking the idea of variables a bit further are mixins.
+These let you group whole bunches of CSS properties into a single
+directive and then include those anywhere you want:
+
+ =blue-border
+ border:
+ color: blue
+ width: 2px
+ style: dotted
+
+ .comment
+ +blue-border
+ padding: 2px
+ margin: 10px 0
+
+ .reply
+ +blue-border
+
+becomes:
+
+ .comment {
+ border-color: blue;
+ border-width: 2px;
+ border-style: dotted;
+ padding: 2px;
+ margin: 10px 0;
+ }
+
+ .reply {
+ border-color: blue;
+ border-width: 2px;
+ border-style: dotted;
+ }
+
+A comprehensive list of features is in
+the documentation for the Sass module.
+
+## Indentation
+
+Indentation can be made up of one or more tabs or spaces.
+However, indentation must be consistent within a given document.
+Hard tabs and spaces can't be mixed,
+and the same number of tabs or spaces must be used throughout.
+
+## Executables
+
+The Haml gem includes several executables that are useful
+for dealing with Haml and Sass from the command line.
+
+### `haml`
+
+The `haml` executable transforms a source Haml file into HTML.
+See `haml --help` for further information and options.
+
+### `sass`
+
+The `sass` executable transforms a source Sass file into CSS.
+See `sass --help` for further information and options.
+
+### `html2haml`
+
+The `html2haml` executable attempts to transform HTML,
+optionally with ERB markup, into Haml code.
+Since HTML is so variable, this transformation is not always perfect;
+it's a good idea to have a human check the output of this tool.
+See `html2haml --help` for further information and options.
+
+### `css2sass`
+
+The `css2sass` executable attempts to transform CSS into Sass code.
+This transformation attempts to use Sass nesting where possible.
+See `css2sass --help` for further information and options.
+
+## Authors
+
+Haml and Sass were created by [Hampton Catlin](http://hamptoncatlin.com)
+(hcatlin) and he is the author of the original implementation. However, Hampton
+doesn't even know his way around the code anymore and now occasionally consults
+on the language issues. Hampton lives in Jacksonville, Florida and is the lead
+mobile developer for Wikimedia.
+
+[Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
+the "modern" Ruby implementation of Haml. His hard work has kept the project
+alive by endlessly answering forum posts, fixing bugs, refactoring, finding
+speed improvements, writing documentation, implementing new features, and
+getting Hampton coffee (a fitting task for a boy-genius). Nathan lives in
+Seattle, Washington and while not being a student at the University of
+Washington or working at an internship, he consults for Unspace Interactive.
+
+[Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to
+Sass and the creator of Compass, the first Sass-based framework. Chris focuses
+on making Sass more powerful, easy to use, and on ways to speed its adoption
+through the web development community. Chris lives in San Jose, California with
+his wife and daughter. He is the Software Architect for
+[Caring.com](http://caring.com), a website devoted to the 34 Million caregivers
+whose parents are sick or elderly, that uses Haml and Sass.
+
+If you use this software, you must pay Hampton a compliment. And
+buy Nathan some jelly beans. Maybe pet a kitten. Yeah. Pet that kitty.
+
+Some of the work on Haml was supported by Unspace Interactive.
+
+Beyond that, the implementation is licensed under the MIT License.
+Okay, fine, I guess that means compliments aren't __required__.
View
1  vendor/haml-2.2.1/REVISION
@@ -0,0 +1 @@
+(release)
View
290 vendor/haml-2.2.1/Rakefile
@@ -0,0 +1,290 @@
+require 'rubygems'
+require 'rake'
+
+# ----- Benchmarking -----
+
+desc <<END
+Benchmark haml against ERb.
+ TIMES=n sets the number of runs. Defaults to 1000.
+END
+task :benchmark do
+ sh "ruby test/benchmark.rb #{ENV['TIMES']}"
+end
+
+# ----- Default: Testing ------
+
+if ENV["RUN_CODE_RUN"] == "true"
+ task :default => :"test:rails_compatibility"
+else
+ task :default => :test
+end
+
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << 'lib'
+ test_files = FileList['test/**/*_test.rb']
+ test_files.exclude('test/rails/*')
+ t.test_files = test_files
+ t.verbose = true
+end
+Rake::Task[:test].send(:add_comment, <<END)
+To run with an alternate version of Rails, make test/rails a symlink to that version.
+END
+
+# ----- Packaging -----
+
+require 'rake/gempackagetask'
+load 'haml.gemspec'
+
+Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
+ if Rake.application.top_level_tasks.include?('release')
+ pkg.need_tar_gz = true
+ pkg.need_tar_bz2 = true
+ pkg.need_zip = true
+ end
+end
+
+task :revision_file do
+ require 'lib/haml'
+
+ release = Rake.application.top_level_tasks.include?('release') || File.exist?('EDGE_GEM_VERSION')
+ if Haml.version[:rev] && !release
+ File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] }
+ elsif release
+ File.open('REVISION', 'w') { |f| f.puts "(release)" }
+ else
+ File.open('REVISION', 'w') { |f| f.puts "(unknown)" }
+ end
+end
+Rake::Task[:package].prerequisites.insert(0, :revision_file)
+
+# We also need to get rid of this file after packaging.
+at_exit { File.delete('REVISION') rescue nil }
+
+desc "Install Haml as a gem."
+task :install => [:package] do
+ sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
+ gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
+ sh %{#{sudo} #{gem} install --no-ri pkg/haml-#{File.read('VERSION').strip}}
+end
+
+desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags."
+task :release => [:package] do
+ name = File.read("VERSION_NAME").strip
+ version = File.read("VERSION").strip
+ raise "VERSION_NAME must not be 'Bleeding Edge'" if name == "Bleeding Edge"
+ sh %{rubyforge login}
+ sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
+ sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
+end
+
+task :release_edge do
+ ensure_git_cleanup do
+ puts "#{'=' * 50} Running rake release_edge"
+
+ sh %{git checkout edge-gem}
+ sh %{git reset --hard origin/edge-gem}
+ sh %{git merge origin/master}
+
+ # Get the current master branch version
+ version = File.read('VERSION').strip.split('.').map {|n| n.to_i}
+ unless version[1] % 2 == 1 && version[2] == 0
+ raise "#{version.join('.')} is not a development version"
+ end
+
+ # Bump the edge gem version
+ edge_version = File.read('EDGE_GEM_VERSION').strip.split('.').map {|n| n.to_i}
+ if edge_version[0..1] != version[0..1]
+ # A new master branch version was released, reset the edge gem version
+ edge_version[0..1] = version[0..1]
+ edge_version[2] = 0
+ else
+ # Just bump the teeny version
+ edge_version[2] += 1
+ end
+ edge_version = edge_version.join('.')
+ File.open('EDGE_GEM_VERSION', 'w') {|f| f.puts(edge_version)}
+ sh %{git commit -m "Bump edge gem version to #{edge_version}." EDGE_GEM_VERSION}
+ sh %{git push origin edge-gem}
+
+ # Package the edge gem with the proper version
+ File.open('VERSION', 'w') {|f| f.puts(edge_version)}
+ sh %{rake package}
+ sh %{git checkout VERSION}
+
+ sh %{rubyforge login}
+ sh %{rubyforge add_release haml haml-edge "Bleeding Edge (v#{edge_version})" pkg/haml-edge-#{edge_version}.gem}
+ end
+end
+
+task :watch_for_update do
+ sh %{ruby extra/update_watch.rb}
+end
+
+# ----- Documentation -----
+
+task :rdoc do
+ puts '=' * 100, <<END, '=' * 100
+Haml uses the YARD documentation system (http://github.com/lsegal/yard).
+Install the yard gem and then run "rake doc".
+END
+end
+
+begin
+ require 'yard'
+
+ YARD::Rake::YardocTask.new do |t|
+ t.files = FileList.new('lib/**/*.rb') do |list|
+ list.exclude('lib/haml/template/*.rb')
+ list.exclude('lib/haml/helpers/action_view_mods.rb')
+ end.to_a
+ t.options << '--use-cache' if Rake.application.top_level_tasks.include?('redoc')
+ t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
+ files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
+ t.options << '--files' << files.join(',')
+ end
+ Rake::Task['yardoc'].instance_variable_set('@comment', nil)
+
+ desc "Generate Documentation"
+ task :doc => :yardoc
+ task :redoc => :yardoc
+rescue LoadError
+ desc "Generate Documentation"
+ task :doc => :rdoc
+ task :yardoc => :rdoc
+end
+
+task :pages do
+ ensure_git_cleanup do
+ puts "#{'=' * 50} Running rake pages PROJ=#{ENV["PROJ"].inspect}"
+ raise 'No ENV["PROJ"]!' unless proj = ENV["PROJ"]
+ sh %{git checkout #{proj}-pages}
+ sh %{git reset --hard origin/#{proj}-pages}
+
+ sh %{rake build --trace}
+ sh %{rsync -av --delete site/ /var/www/#{proj}-pages}
+ end
+end
+
+# ----- Coverage -----
+
+begin
+ require 'rcov/rcovtask'
+
+ Rcov::RcovTask.new do |t|
+ t.test_files = FileList['test/**/*_test.rb']
+ t.rcov_opts << '-x' << '"^\/"'
+ if ENV['NON_NATIVE']
+ t.rcov_opts << "--no-rcovrt"
+ end
+ t.verbose = true
+ end
+rescue LoadError; end
+
+# ----- Profiling -----
+
+begin
+ require 'ruby-prof'
+
+ desc <<END
+Run a profile of haml.
+ ENGINE=str sets the engine to be profiled. Defaults to Haml.
+ TIMES=n sets the number of runs. Defaults to 1000.
+ FILE=str sets the file to profile.
+ Defaults to 'standard' for Haml and 'complex' for Sass.
+ OUTPUT=str sets the ruby-prof output format.
+ Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
+END
+ task :profile do
+ engine = (ENV['ENGINE'] || 'haml').downcase
+ times = (ENV['TIMES'] || '1000').to_i
+ file = ENV['FILE']
+
+ if engine == 'sass'
+ require 'lib/sass'
+
+ file = File.read("#{File.dirname(__FILE__)}/test/sass/templates/#{file || 'complex'}.sass")
+ result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
+ else
+ require 'lib/haml'
+
+ file = File.read("#{File.dirname(__FILE__)}/test/haml/templates/#{file || 'standard'}.haml")
+ obj = Object.new
+ Haml::Engine.new(file).def_method(obj, :render)
+ result = RubyProf.profile { times.times { obj.render } }
+ end
+
+ RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
+ end
+rescue LoadError; end
+
+# ----- Testing Multiple Rails Versions -----
+
+rails_versions = [
+ "v2.3.0",
+ "v2.2.2",
+ "v2.1.2",
+ "v2.0.5"
+]
+
+namespace :test do
+ desc "Test all supported versions of rails. This takes a while."
+ task :rails_compatibility do
+ `rm -rf test/rails`
+ puts "Checking out rails. Please wait."
+ `git clone git://github.com/rails/rails.git test/rails` rescue nil
+ begin
+ rails_versions.each do |version|
+ Dir.chdir "test/rails" do
+ `git checkout #{version}`
+ end
+ puts "Testing Rails #{version}"
+ Rake::Task['test'].reenable
+ Rake::Task['test'].execute
+ end
+ ensure
+ `rm -rf test/rails`
+ end
+ end
+end
+
+# ----- Handling Updates -----
+
+def ensure_git_cleanup
+ yield
+ensure
+ sh %{git reset --hard HEAD}
+ sh %{git clean -xdf}
+ sh %{git checkout master}
+end
+
+task :handle_update do
+ unless ENV["REF"] =~ %r{^refs/heads/(master|(?:haml|sass)-pages)$}
+ puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
+ next
+ end
+ branch = $1
+
+ puts
+ puts
+ puts '=' * 150
+ puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
+
+ sh %{git checkout master}
+ sh %{git fetch origin}
+ sh %{git reset --hard origin/master}
+
+ if branch == "master"
+ sh %{rake release_edge --trace}
+ sh %{rake pages --trace PROJ=haml}
+ sh %{rake pages --trace PROJ=sass}
+ elsif branch =~ /^(haml|sass)-pages$/
+ sh %{rake pages --trace PROJ=#{$1}}
+ end
+
+ puts 'Done running handle_update'
+ puts '=' * 150
+end
View
1  vendor/haml-2.2.1/VERSION
@@ -0,0 +1 @@
+2.2.1
View
1  vendor/haml-2.2.1/VERSION_NAME
@@ -0,0 +1 @@
+Powerful Penny
View
7 vendor/haml-2.2.1/bin/css2sass
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../lib/haml'
+require 'haml/exec'
+
+opts = Haml::Exec::CSS2Sass.new(ARGV)
+opts.parse!
View
9 vendor/haml-2.2.1/bin/haml
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+# The command line Haml parser.
+
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
+require 'haml'
+require 'haml/exec'
+
+opts = Haml::Exec::Haml.new(ARGV)
+opts.parse!
View
7 vendor/haml-2.2.1/bin/html2haml
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../lib/haml'
+require 'haml/exec'
+
+opts = Haml::Exec::HTML2Haml.new(ARGV)
+opts.parse!
View
8 vendor/haml-2.2.1/bin/sass
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+# The command line Sass parser.
+
+require File.dirname(__FILE__) + '/../lib/haml'
+require 'haml/exec'
+
+opts = Haml::Exec::Sass.new(ARGV)
+opts.parse!
View
650 vendor/haml-2.2.1/extra/haml-mode.el
@@ -0,0 +1,650 @@
+;;; haml-mode.el --- Major mode for editing Haml files
+
+;; Copyright (c) 2007, 2008 Nathan Weizenbaum
+
+;; Author: Nathan Weizenbaum
+;; URL: http://github.com/nex3/haml/tree/master
+;; Version: 1.0
+;; Keywords: markup, language
+
+;;; Commentary:
+
+;; Because Haml's indentation schema is similar
+;; to that of YAML and Python, many indentation-related
+;; functions are similar to those in yaml-mode and python-mode.
+
+;; To install, save this on your load path and add the following to
+;; your .emacs file:
+;;
+;; (require 'haml-mode)
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ruby-mode)
+
+;; User definable variables
+
+(defgroup haml nil
+ "Support for the Haml template language."
+ :group 'languages
+ :prefix "haml-")
+
+(defcustom haml-mode-hook nil
+ "Hook run when entering Haml mode."
+ :type 'hook
+ :group 'haml)
+
+(defcustom haml-indent-offset 2
+ "Amount of offset per level of indentation."
+ :type 'integer
+ :group 'haml)
+
+(defcustom haml-backspace-backdents-nesting t
+ "Non-nil to have `haml-electric-backspace' re-indent all code
+nested beneath the backspaced line be re-indented along with the
+line itself."
+ :type 'boolean
+ :group 'haml)
+
+(defface haml-tab-face
+ '((((class color)) (:background "hotpink"))
+ (t (:reverse-video t)))
+ "Face to use for highlighting tabs in Haml files."
+ :group 'faces
+ :group 'haml)
+
+(defvar haml-indent-function 'haml-indent-p
+ "This function should look at the current line and return t
+if the next line could be nested within this line.
+
+The function can also return a positive integer to indicate
+a specific level to which the current line could be indented.")
+
+(defconst haml-tag-beg-re
+ "^ *\\(?:[%\\.#][a-z0-9_:\\-]*\\)+\\(?:(.*)\\|{.*}\\|\\[.*\\]\\)*"
+ "A regexp matching the beginning of a Haml tag, through (), {}, and [].")
+
+(defvar haml-block-openers
+ `(,(concat haml-tag-beg-re "[><]*[ \t]*$")
+ "^ *[&!]?[-=~].*do[ \t]*\\(|.*|[ \t]*\\)?$"
+ ,(concat "^ *[&!]?[-=~][ \t]*\\("
+ (regexp-opt '("if" "unless" "while" "until" "else"
+ "begin" "elsif" "rescue" "ensure" "when"))
+ "\\)")
+ "^ */\\(\\[.*\\]\\)?[ \t]*$"
+ "^ *-#"
+ "^ *:")
+ "A list of regexps that match lines of Haml that could have
+text nested beneath them.")
+
+;; Font lock
+
+(defun haml-nested-regexp (re)
+ (concat "^\\( *\\)" re "\\(\n\\(?:\\(?:\\1 .*\\| *\\)\n\\)*\\(?:\\1 .*\\| *\\)?\\)?"))
+
+(defconst haml-font-lock-keywords
+ `((,(haml-nested-regexp "\\(?:-#\\|/\\).*") 0 font-lock-comment-face)
+ (,(haml-nested-regexp ":\\w+") 0 font-lock-string-face)
+ (haml-highlight-interpolation 1 font-lock-variable-name-face prepend)
+ (haml-highlight-ruby-tag 1 font-lock-preprocessor-face)
+ (haml-highlight-ruby-script 1 font-lock-preprocessor-face)
+ ("^ *\\(\t\\)" 1 'haml-tab-face)
+ ("^!!!.*" 0 font-lock-constant-face)
+ ("| *$" 0 font-lock-string-face)))
+
+(defconst haml-filter-re "^ *:\\w+")
+(defconst haml-comment-re "^ *\\(?:-\\#\\|/\\)")
+
+(defun haml-fontify-region-as-ruby (beg end)
+ "Use Ruby's font-lock variables to fontify the region between BEG and END."
+ (save-excursion
+ (save-match-data
+ (let ((font-lock-keywords ruby-font-lock-keywords)
+ (font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)
+ font-lock-keywords-only
+ font-lock-extend-region-functions
+ font-lock-keywords-case-fold-search)
+ ;; font-lock-fontify-region apparently isn't inclusive,
+ ;; so we have to move the beginning back one char
+ (font-lock-fontify-region (- beg 1) end)))))
+
+(defun haml-highlight-ruby-script (limit)
+ "Highlight a Ruby script expression (-, =, or ~)."
+ (when (re-search-forward "^ *\\(-\\|[&!]?[=~]\\) \\(.*\\)$" limit t)
+ (haml-fontify-region-as-ruby (match-beginning 2) (match-end 2))))
+
+(defun haml-highlight-ruby-tag (limit)
+ "Highlight Ruby code within a Haml tag.
+
+This highlights the tag attributes and object refs of the tag,
+as well as the script expression (-, =, or ~) following the tag.
+
+For example, this will highlight all of the following:
+ %p{:foo => 'bar'}
+ %p[@bar]
+ %p= 'baz'
+ %p{:foo => 'bar'}[@bar]= 'baz'"
+ (when (re-search-forward "^ *[%.#]" limit t)
+ (forward-char -1)
+
+ ;; Highlight tag, classes, and ids
+ (while (haml-move "\\([.#%]\\)[a-z0-9_:\\-]*")
+ (put-text-property (match-beginning 0) (match-end 0) 'face
+ (case (char-after (match-beginning 1))
+ (?% font-lock-function-name-face)
+ (?# font-lock-keyword-face)
+ (?. font-lock-type-face))))
+
+ (block loop
+ (while t
+ (let ((eol (save-excursion (end-of-line) (point))))
+ (case (char-after)
+ ;; Highlight obj refs
+ (?\[
+ (let ((beg (point)))
+ (haml-limited-forward-sexp eol)
+ (haml-fontify-region-as-ruby beg (point))))
+ ;; Highlight new attr hashes
+ (?\(
+ (forward-char 1)
+ (while
+ (and (haml-parse-new-attr-hash
+ (lambda (type beg end)
+ (case type
+ (name (put-text-property beg end 'face font-lock-constant-face))
+ (value (haml-fontify-region-as-ruby beg end)))))
+ (not (eobp)))
+ (forward-line 1)
+ (beginning-of-line)))
+ ;; Highlight old attr hashes
+ (?\{
+ (let ((beg (point)))
+ (haml-limited-forward-sexp eol)
+
+ ;; Check for multiline
+ (while (and (eolp) (eq (char-before) ?,) (not (eobp)))
+ (forward-line)
+ (let ((eol (save-excursion (end-of-line) (point))))
+ ;; If no sexps are closed,
+ ;; we're still continuing a multiline hash
+ (if (>= (car (parse-partial-sexp (point) eol)) 0)
+ (end-of-line)
+ ;; If sexps have been closed,
+ ;; set the point at the end of the total sexp
+ (goto-char beg)
+ (haml-limited-forward-sexp eol))))
+
+ (haml-fontify-region-as-ruby (+ 1 beg) (point))))
+ (t (return-from loop))))))
+
+ ;; Move past end chars
+ (when (looking-at "[<>&!]+") (goto-char (match-end 0)))
+ ;; Highlight script
+ (if (looking-at "\\([=~]\\) \\(.*\\)$")
+ (haml-fontify-region-as-ruby (match-beginning 2) (match-end 2))
+ ;; Give font-lock something to highlight
+ (forward-char -1)
+ (looking-at "\\(\\)"))
+ t))
+
+(defun haml-move (re)
+ "Try matching and moving to the end of a regular expression."
+ (when (looking-at re)
+ (goto-char (match-end 0))
+ t))
+
+(defun haml-highlight-interpolation (limit)
+ "Highlight Ruby interpolation (#{foo})."
+ (when (re-search-forward "\\(#{\\)" limit t)
+ (save-match-data
+ (forward-char -1)
+ (let ((beg (point)))
+ (haml-limited-forward-sexp limit)
+ (haml-fontify-region-as-ruby (+ 1 beg) (point)))
+
+ (when (eq (char-before) ?})
+ (put-text-property (- (point) 1) (point)
+ 'face font-lock-variable-name-face))
+ t)))
+
+(defun haml-limited-forward-sexp (limit &optional arg)
+ "Move forward using `forward-sexp' or to limit,
+whichever comes first."
+ (let (forward-sexp-function)
+ (condition-case err
+ (save-restriction
+ (narrow-to-region (point) limit)
+ (forward-sexp arg))
+ (scan-error
+ (unless (equal (nth 1 err) "Unbalanced parentheses")
+ (signal 'scan-error (cdr err)))
+ (goto-char limit)))))
+
+(defun* haml-extend-region-filters-comments ()
+ "Extend the font-lock region to encompass filters and comments."
+ (let ((old-beg font-lock-beg)
+ (old-end font-lock-end))
+ (save-excursion
+ (goto-char font-lock-beg)
+ (beginning-of-line)
+ (unless (or (looking-at haml-filter-re)
+ (looking-at haml-comment-re))
+ (return-from haml-extend-region-filters-comments))
+ (setq font-lock-beg (point))
+ (haml-forward-sexp)
+ (beginning-of-line)
+ (setq font-lock-end (max font-lock-end (point))))
+ (or (/= old-beg font-lock-beg)
+ (/= old-end font-lock-end))))
+
+(defun* haml-extend-region-multiline-hashes ()
+ "Extend the font-lock region to encompass multiline attribute hashes."
+ (let ((old-beg font-lock-beg)
+ (old-end font-lock-end))
+ (save-excursion
+ (goto-char font-lock-beg)
+ (let ((attr-props (haml-parse-multiline-attr-hash))
+ multiline-end)
+ (when attr-props
+ (setq font-lock-beg (cdr (assq 'point attr-props)))
+
+ (end-of-line)
+ ;; Move through multiline attrs
+ (when (eq (char-before) ?,)
+ (save-excursion
+ (while (progn (end-of-line) (eq (char-before) ?,) (not (eobp)))
+ (forward-line))
+
+ (forward-line -1)
+ (end-of-line)
+ (setq multiline-end (point))))
+
+ (goto-char (+ (cdr (assq 'point attr-props))
+ (cdr (assq 'hash-indent attr-props))
+ -1))
+ (haml-limited-forward-sexp
+ (or multiline-end
+ (save-excursion (end-of-line) (point))))
+ (setq font-lock-end (max font-lock-end (point))))))
+ (or (/= old-beg font-lock-beg)
+ (/= old-end font-lock-end))))
+
+
+;; Mode setup
+
+(defvar haml-mode-syntax-table
+ (let ((table (make-syntax-table)))
+ (modify-syntax-entry ?: "." table)
+ (modify-syntax-entry ?_ "w" table)
+ table)
+ "Syntax table in use in haml-mode buffers.")
+
+(defvar haml-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [backspace] 'haml-electric-backspace)
+ (define-key map "\C-?" 'haml-electric-backspace)
+ (define-key map "\C-c\C-f" 'haml-forward-sexp)
+ (define-key map "\C-c\C-b" 'haml-backward-sexp)
+ (define-key map "\C-c\C-u" 'haml-up-list)
+ (define-key map "\C-c\C-d" 'haml-down-list)
+ (define-key map "\C-c\C-k" 'haml-kill-line-and-indent)
+ (define-key map "\C-c\C-r" 'haml-output-region)
+ (define-key map "\C-c\C-l" 'haml-output-buffer)
+ map))
+
+;;;###autoload
+(define-derived-mode haml-mode fundamental-mode "Haml"
+ "Major mode for editing Haml files.
+
+\\{haml-mode-map}"
+ (set-syntax-table haml-mode-syntax-table)
+ (add-to-list 'font-lock-extend-region-functions 'haml-extend-region-filters-comments)
+ (add-to-list 'font-lock-extend-region-functions 'haml-extend-region-multiline-hashes)
+ (set (make-local-variable 'font-lock-multiline) t)
+ (set (make-local-variable 'indent-line-function) 'haml-indent-line)
+ (set (make-local-variable 'indent-region-function) 'haml-indent-region)
+ (set (make-local-variable 'parse-sexp-lookup-properties) t)
+ (setq comment-start "-#")
+ (setq indent-tabs-mode nil)
+ (setq font-lock-defaults '((haml-font-lock-keywords) t t)))
+
+;; Useful functions
+
+(defun haml-comment-block ()
+ "Comment the current block of Haml code."
+ (interactive)
+ (save-excursion
+ (let ((indent (current-indentation)))
+ (back-to-indentation)
+ (insert "-#")
+ (newline)
+ (indent-to indent)
+ (beginning-of-line)
+ (haml-mark-sexp)
+ (haml-reindent-region-by haml-indent-offset))))
+
+(defun haml-uncomment-block ()
+ "Uncomment the current block of Haml code."
+ (interactive)
+ (save-excursion
+ (beginning-of-line)
+ (while (not (looking-at haml-comment-re))
+ (haml-up-list)
+ (beginning-of-line))
+ (haml-mark-sexp)
+ (kill-line 1)
+ (haml-reindent-region-by (- haml-indent-offset))))
+
+(defun haml-replace-region (start end)
+ "Replaces the current block of Haml code with the HTML equivalent."
+ (interactive "r")
+ (save-excursion
+ (goto-char end)
+ (setq end (point-marker))
+ (goto-char start)
+ (let ((ci (current-indentation)))
+ (while (re-search-forward "^ +" end t)
+ (replace-match (make-string (- (current-indentation) ci) ? ))))
+ (shell-command-on-region start end "haml" "haml-output" t)))
+
+(defun haml-output-region (start end)
+ "Displays the HTML output for the current block of Haml code."
+ (interactive "r")
+ (kill-new (buffer-substring start end))
+ (with-temp-buffer
+ (yank)
+ (haml-indent-region (point-min) (point-max))
+ (shell-command-on-region (point-min) (point-max) "haml" "haml-output")))
+
+(defun haml-output-buffer ()
+ "Displays the HTML output for entire buffer."
+ (interactive)
+ (haml-output-region (point-min) (point-max)))
+
+;; Navigation
+
+(defun haml-forward-through-whitespace (&optional backward)
+ "Move the point forward at least one line, until it reaches
+either the end of the buffer or a line with no whitespace.
+
+If `backward' is non-nil, move the point backward instead."
+ (let ((arg (if backward -1 1))
+ (endp (if backward 'bobp 'eobp)))
+ (loop do (forward-line arg)
+ while (and (not (funcall endp))
+ (looking-at "^[ \t]*$")))))
+
+(defun haml-at-indent-p ()
+ "Returns whether or not the point is at the first
+non-whitespace character in a line or whitespace preceding that
+character."
+ (let ((opoint (point)))
+ (save-excursion
+ (back-to-indentation)
+ (>= (point) opoint))))
+
+(defun haml-forward-sexp (&optional arg)
+ "Move forward across one nested expression.
+With `arg', do it that many times. Negative arg -N means move
+backward across N balanced expressions.
+
+A sexp in Haml is defined as a line of Haml code as well as any
+lines nested beneath it."
+ (interactive "p")
+ (or arg (setq arg 1))
+ (if (and (< arg 0) (not (haml-at-indent-p)))
+ (back-to-indentation)
+ (while (/= arg 0)
+ (let ((indent (current-indentation)))
+ (loop do (haml-forward-through-whitespace (< arg 0))
+ while (and (not (eobp))
+ (not (bobp))
+ (> (current-indentation) indent)))
+ (back-to-indentation)
+ (setq arg (+ arg (if (> arg 0) -1 1)))))))
+
+(defun haml-backward-sexp (&optional arg)
+ "Move backward across one nested expression.
+With ARG, do it that many times. Negative arg -N means move
+forward across N balanced expressions.
+
+A sexp in Haml is defined as a line of Haml code as well as any
+lines nested beneath it."
+ (interactive "p")
+ (haml-forward-sexp (if arg (- arg) -1)))
+
+(defun haml-up-list (&optional arg)
+ "Move out of one level of nesting.
+With ARG, do this that many times."
+ (interactive "p")
+ (or arg (setq arg 1))
+ (while (> arg 0)
+ (let ((indent (current-indentation)))
+ (loop do (haml-forward-through-whitespace t)
+ while (and (not (bobp))
+ (>= (current-indentation) indent)))
+ (setq arg (- arg 1))))
+ (back-to-indentation))
+
+(defun haml-down-list (&optional arg)
+ "Move down one level of nesting.
+With ARG, do this that many times."
+ (interactive "p")
+ (or arg (setq arg 1))
+ (while (> arg 0)
+ (let ((indent (current-indentation)))
+ (haml-forward-through-whitespace)
+ (when (<= (current-indentation) indent)
+ (haml-forward-through-whitespace t)
+ (back-to-indentation)
+ (error "Nothing is nested beneath this line"))
+ (setq arg (- arg 1))))
+ (back-to-indentation))
+
+(defun haml-mark-sexp ()
+ "Marks the next Haml block."
+ (let ((forward-sexp-function 'haml-forward-sexp))
+ (mark-sexp)))
+
+(defun haml-mark-sexp-but-not-next-line ()
+ "Marks the next Haml block, but puts the mark at the end of the
+last line of the sexp rather than the first non-whitespace
+character of the next line."
+ (haml-mark-sexp)
+ (set-mark
+ (save-excursion
+ (goto-char (mark))
+ (forward-line -1)
+ (end-of-line)
+ (point))))
+
+;; Indentation and electric keys
+
+(defun* haml-indent-p ()
+ "Returns t if the current line can have lines nested beneath it."
+ (let ((attr-props (haml-parse-multiline-attr-hash)))
+ (when attr-props
+ (return-from haml-indent-p
+ (if (haml-unclosed-attr-hash-p) (cdr (assq 'hash-indent attr-props))
+ (list (+ (cdr (assq 'indent attr-props)) haml-indent-offset) nil)))))
+ (loop for opener in haml-block-openers
+ if (looking-at opener) return t
+ finally return nil))
+
+(defun* haml-parse-multiline-attr-hash ()
+ "Parses a multiline attribute hash, and returns
+an alist with the following keys:
+
+INDENT is the indentation of the line beginning the hash.
+
+HASH-INDENT is the indentation of the first character
+within the attribute hash.
+
+POINT is the character position at the beginning of the line
+beginning the hash."
+ (save-excursion
+ (while t
+ (beginning-of-line)
+ (if (looking-at (eval-when-compile (concat haml-tag-beg-re "\\([{(]\\)")))
+ (progn
+ (goto-char (- (match-end 0) 1))
+ (haml-limited-forward-sexp (save-excursion (end-of-line) (point)))
+ (return-from haml-parse-multiline-attr-hash
+ (when (or (string-equal (match-string 1) "(") (eq (char-before) ?,))
+ `((indent . ,(current-indentation))
+ (hash-indent . ,(- (match-end 0) (match-beginning 0)))
+ (point . ,(match-beginning 0))))))
+ (when (bobp) (return-from haml-parse-multiline-attr-hash))
+ (forward-line -1)
+ (unless (haml-unclosed-attr-hash-p)
+ (return-from haml-parse-multiline-attr-hash))))))
+
+(defun* haml-unclosed-attr-hash-p ()
+ "Return t if this line has an unclosed attribute hash, new or old."
+ (save-excursion
+ (end-of-line)
+ (when (eq (char-before) ?,) (return-from haml-unclosed-attr-hash-p t))
+ (re-search-backward "(\\|^")
+ (haml-move "(")
+ (haml-parse-new-attr-hash)))
+
+(defun* haml-parse-new-attr-hash (&optional (fn (lambda (type beg end) ())))
+ "Parse a new-style attribute hash on this line, and returns
+t if it's not finished on the current line.
+
+FN should take three parameters: TYPE, BEG, and END.
+TYPE is the type of text parsed ('name or 'value)
+and BEG and END delimit that text in the buffer."
+ (let ((eol (save-excursion (end-of-line) (point))))
+ (while (not (haml-move ")"))
+ (haml-move " *")
+ (unless (haml-move "[a-z0-9_:\\-]+")
+ (return-from haml-parse-new-attr-hash (haml-move " *$")))
+ (funcall fn 'name (match-beginning 0) (match-end 0))
+ (haml-move " *")
+ (when (haml-move "=")
+ (haml-move " *")
+ (unless (looking-at "[\"'@a-z]") (return-from haml-parse-new-attr-hash))
+ (let ((beg (point)))
+ (haml-limited-forward-sexp eol)
+ (funcall fn 'value beg (point)))
+ (haml-move " *")))
+ nil))
+
+(defun haml-compute-indentation ()
+ "Calculate the maximum sensible indentation for the current line."
+ (save-excursion
+ (beginning-of-line)
+ (if (bobp) (list 0 nil)
+ (haml-forward-through-whitespace t)
+ (let ((indent (funcall haml-indent-function)))
+ (cond
+ ((consp indent) indent)
+ ((integerp indent) (list indent t))
+ (indent (list (+ (current-indentation) haml-indent-offset) nil))
+ (t (list (current-indentation) nil)))))))
+
+(defun haml-indent-region (start end)
+ "Indent each nonblank line in the region.
+This is done by indenting the first line based on
+`haml-compute-indentation' and preserving the relative
+indentation of the rest of the region.
+
+If this command is used multiple times in a row, it will cycle
+between possible indentations."
+ (save-excursion
+ (goto-char end)
+ (setq end (point-marker))
+ (goto-char start)
+ (let (this-line-column current-column
+ (next-line-column
+ (if (and (equal last-command this-command) (/= (current-indentation) 0))
+ (* (/ (- (current-indentation) 1) haml-indent-offset) haml-indent-offset)
+ (car (haml-compute-indentation)))))
+ (while (< (point) end)
+ (setq this-line-column next-line-column
+ current-column (current-indentation))
+ ;; Delete whitespace chars at beginning of line
+ (delete-horizontal-space)
+ (unless (eolp)
+ (setq next-line-column (save-excursion
+ (loop do (forward-line 1)
+ while (and (not (eobp)) (looking-at "^[ \t]*$")))
+ (+ this-line-column
+ (- (current-indentation) current-column))))
+ ;; Don't indent an empty line
+ (unless (eolp) (indent-to this-line-column)))
+ (forward-line 1)))
+ (move-marker end nil)))
+
+(defun haml-indent-line ()
+ "Indent the current line.
+The first time this command is used, the line will be indented to the
+maximum sensible indentation. Each immediately subsequent usage will
+back-dent the line by `haml-indent-offset' spaces. On reaching column
+0, it will cycle back to the maximum sensible indentation."
+ (interactive "*")
+ (let ((ci (current-indentation))
+ (cc (current-column)))
+ (destructuring-bind (need strict) (haml-compute-indentation)
+ (save-excursion
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (if (and (not strict) (equal last-command this-command) (/= ci 0))
+ (indent-to (* (/ (- ci 1) haml-indent-offset) haml-indent-offset))
+ (indent-to need))))
+ (when (< (current-column) (current-indentation))
+ (forward-to-indentation 0))))
+
+(defun haml-reindent-region-by (n)
+ "Add N spaces to the beginning of each line in the region.
+If N is negative, will remove the spaces instead. Assumes all
+lines in the region have indentation >= that of the first line."
+ (let ((ci (current-indentation)))
+ (save-excursion
+ (replace-regexp (concat "^" (make-string ci ? ))
+ (make-string (max 0 (+ ci n)) ? )
+ nil (point) (mark)))))
+
+(defun haml-electric-backspace (arg)
+ "Delete characters or back-dent the current line.
+If invoked following only whitespace on a line, will back-dent
+the line and all nested lines to the immediately previous
+multiple of `haml-indent-offset' spaces.
+
+Set `haml-backspace-backdents-nesting' to nil to just back-dent
+the current line."
+ (interactive "*p")
+ (if (or (/= (current-indentation) (current-column))
+ (bolp)
+ (looking-at "^[ \t]+$"))
+ (backward-delete-char arg)
+ (save-excursion
+ (let ((ci (current-column)))
+ (beginning-of-line)
+ (if haml-backspace-backdents-nesting
+ (haml-mark-sexp-but-not-next-line)
+ (set-mark (save-excursion (end-of-line) (point))))
+ (haml-reindent-region-by (* (- arg) haml-indent-offset))
+ (back-to-indentation)
+ (pop-mark)))))
+
+(defun haml-kill-line-and-indent ()
+ "Kill the current line, and re-indent all lines nested beneath it."
+ (interactive)
+ (beginning-of-line)
+ (haml-mark-sexp-but-not-next-line)
+ (kill-line 1)
+ (haml-reindent-region-by (* -1 haml-indent-offset)))
+
+(defun haml-indent-string ()
+ "Return the indentation string for `haml-indent-offset'."
+ (mapconcat 'identity (make-list haml-indent-offset " ") ""))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.haml$" . haml-mode))
+
+;; Setup/Activation
+(provide 'haml-mode)
+;;; haml-mode.el ends here
View
201 vendor/haml-2.2.1/extra/sass-mode.el
@@ -0,0 +1,201 @@
+;;; sass-mode.el --- Major mode for editing Sass files
+
+;; Copyright (c) 2007, 2008 Nathan Weizenbaum
+
+;; Author: Nathan Weizenbaum
+;; URL: http://github.com/nex3/haml/tree/master
+;; Version: 1.0
+;; Keywords: markup, language
+
+;;; Commentary:
+
+;; Because Sass's indentation schema is similar
+;; to that of YAML and Python, many indentation-related
+;; functions are similar to those in yaml-mode and python-mode.
+
+;; To install, save this on your load path and add the following to
+;; your .emacs file:
+;;
+;; (require 'sass-mode)
+
+;;; Code:
+
+(require 'haml-mode)
+
+;; User definable variables
+
+(defgroup sass nil
+ "Support for the Sass template language."
+ :group 'languages
+ :prefix "sass-")
+
+(defcustom sass-mode-hook nil
+ "Hook run when entering Sass mode."
+ :type 'hook
+ :group 'sass)
+
+(defcustom sass-indent-offset 2
+ "Amount of offset per level of indentation."
+ :type 'integer
+ :group 'sass)
+
+(defvar sass-non-block-openers
+ '("^ *:[^ \t]+[ \t]+[^ \t]"
+ "^ *[^ \t:]+[ \t]*[=:][ \t]*[^ \t]")
+ "A list of regexps that match lines of Sass that couldn't have
+text nested beneath them.")
+
+;; Font lock
+
+(defconst sass-selector-font-lock-keywords
+ '(;; Attribute selectors (e.g. p[foo=bar])
+ ("\\[\\([^]=]+\\)" (1 font-lock-variable-name-face)
+ ("[~|$^*]?=\\([^]=]+\\)" nil nil (1 font-lock-string-face)))
+ ("&" 0 font-lock-constant-face)
+ ("\\.\\w+" 0 font-lock-type-face)
+ ("#\\w+" 0 font-lock-keyword-face)
+ ;; Pseudo-selectors, optionally with arguments (e.g. :first, :nth-child(12))
+ ("\\(::?\\w+\\)" (1 font-lock-function-name-face)
+ ("(\\([^)]+\\))" nil nil (1 font-lock-string-face)))))
+
+(defconst sass-script-font-lock-keywords
+ `(("\"\\([^\"\\\\]\\|\\\\.\\)*\"" 0 font-lock-string-face)
+ ("!\\(\\w\\|_\\)+" 0 font-lock-variable-name-face)
+ ("#[0-9a-fA-F]\\{0,6\\}" 0 font-lock-preprocessor-face)
+ (,(regexp-opt
+ '("true" "false" "black" "silver" "gray" "white" "maroon" "red"
+ "purple" "fuchsia" "green" "lime" "olive" "yellow" "navy"
+ "blue" "teal" "aqua"))
+ 0 font-lock-constant-face)
+ (,(regexp-opt '("and" "or" "not")) 0 font-lock-keyword-face)))
+
+(defconst sass-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?- "w" st)
+ (modify-syntax-entry ?_ "w" st)
+ st))
+
+(defconst sass-script-syntax-table
+ (let ((st (make-syntax-table sass-syntax-table)))
+ (modify-syntax-entry ?- "." st)
+ st))
+
+(defconst sass-font-lock-keywords
+ '((sass-highlight-line 1 nil nil t)))
+
+(defconst sass-line-keywords
+ '(("@\\(\\w+\\)" 0 font-lock-keyword-face sass-highlight-directive)
+ ("/[/*].*" 0 font-lock-comment-face)
+ ("[=+]\\w+" 0 font-lock-function-name-face sass-highlight-script-after-match)
+ ("!\\w+" 0 font-lock-variable-name-face sass-highlight-script-after-match)
+ (":\\w+" 0 font-lock-variable-name-face)
+ ("\\w+\s*:" 0 font-lock-variable-name-face)
+ ("\\(\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match)
+ ("\\(:\\w+\\)\s*=" 1 font-lock-variable-name-face sass-highlight-script-after-match)
+ (".*" sass-highlight-selector))
+ "A list of full-line Sass syntax to highlight,
+used by `sass-highlight-line'.
+
+Each item is either of the form (REGEXP SUBEXP FACE), (REGEXP FN),
+or (REGEXP SUBEXP FACE FN). Each REGEXP is run successively on the
+beginning of non-whitespace on the current line until one matches.
+If it has SUBEXP and FACE, then SUBEXP is highlighted using FACE.
+If it has FN, FN is run.")
+
+(defun sass-highlight-line (limit)
+ "Highlight a single line using some Sass single-line syntax,
+taken from `sass-line-keywords'."
+ (save-match-data
+ (when (re-search-forward "^ *\\(.+\\)$" limit t)
+ (goto-char (match-beginning 1))
+ (dolist (keyword sass-line-keywords)
+ (destructuring-bind (keyword subexp-or-fn &optional face fn) keyword
+ (when (looking-at keyword)
+ (if (integerp subexp-or-fn)
+ (put-text-property (match-beginning subexp-or-fn)
+ (match-end subexp-or-fn)
+ 'face face)
+ (setq fn subexp-or-fn))
+ (when fn (funcall fn))
+ (end-of-line)
+ (return t)))))))
+
+(defun sass-highlight-selector ()
+ "Highlight a CSS selector starting at `point'
+and ending at `end-of-line'."
+ (let ((font-lock-keywords sass-selector-font-lock-keywords)
+ font-lock-multiline)
+ (font-lock-fontify-region
+ (point) (progn (end-of-line) (point))))
+ t)
+
+(defun sass-highlight-script (beg end)
+ "Highlight a section of SassScript between BEG and END."
+ (save-match-data
+ (with-syntax-table sass-script-syntax-table
+ (let ((font-lock-keywords sass-script-font-lock-keywords)
+ font-lock-syntax-table
+ font-lock-extend-region-functions)
+ (font-lock-fontify-region beg end)))))
+
+(defun sass-highlight-script-after-match ()
+ (end-of-line)
+ (sass-highlight-script (match-end 0) (point)))
+
+(defun sass-highlight-directive ()
+ (goto-char (match-end 0))
+ (block nil
+ (case (intern (match-string 1))
+ (for
+ (unless (looking-at " +!\\w+") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-variable-name-face)
+ (goto-char (match-end 0))
+ (unless (looking-at " +from") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-keyword-face)
+ (goto-char (match-end 0))
+ (when (looking-at " +\\(.+?\\) +\\(to\\|through\\)")
+ (sass-highlight-script (match-beginning 1) (match-end 1))
+ (put-text-property (match-beginning 2) (match-end 2)
+ 'face font-lock-keyword-face))
+ (sass-highlight-script-after-match))
+
+ (else
+ (unless (looking-at " +if") (return))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'face font-lock-keyword-face)
+ (sass-highlight-script-after-match))
+
+ ((if while debug) (sass-highlight-script-after-match)))))
+
+;; Constants
+
+;; Mode setup
+
+;;;###autoload
+(define-derived-mode sass-mode haml-mode "Sass"
+ "Major mode for editing Sass files."
+ (set-syntax-table sass-syntax-table)
+ (setq font-lock-extend-region-functions
+ '(font-lock-extend-region-wholelines font-lock-extend-region-multiline))
+ (setq font-lock-multiline nil)
+ (setq comment-start "/*")
+ (set (make-local-variable 'haml-indent-function) 'sass-indent-p)
+ (set (make-local-variable 'haml-indent-offset) sass-indent-offset)
+ (setq font-lock-defaults '(sass-font-lock-keywords t t)))
+
+;; Indentation
+
+(defun sass-indent-p ()
+ "Returns t if the current line can have lines nested beneath it."
+ (loop for opener in sass-non-block-openers
+ unless (looking-at opener) return t
+ return nil))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
+
+;; Setup/Activation
+(provide 'sass-mode)
+;;; sass-mode.el ends here
View
13 vendor/haml-2.2.1/extra/update_watch.rb
@@ -0,0 +1,13 @@
+require 'rubygems'
+require 'sinatra'
+require 'json'
+set :port, 3123
+set :environment, :production
+enable :lock
+Dir.chdir(File.dirname(__FILE__) + "/..")
+
+post "/" do
+ puts "Recieved payload!"
+ puts "Rev: #{`git name-rev HEAD`.strip}"
+ system %{rake handle_update --trace REF=#{JSON.parse(params["payload"])["ref"].inspect}}
+end
View
8 vendor/haml-2.2.1/init.rb
@@ -0,0 +1,8 @@
+begin
+ require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here
+rescue LoadError
+ require 'haml' # From gem
+end
+
+# Load Haml and Sass
+Haml.init_rails(binding)
View
40 vendor/haml-2.2.1/lib/haml.rb
@@ -0,0 +1,40 @@
+dir = File.dirname(__FILE__)
+$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
+
+require 'haml/version'
+
+# The module that contains everything Haml-related:
+#
+# * {Haml::Engine} is the class used to render Haml within Ruby code.
+# * {Haml::Helpers} contains Ruby helpers available within Haml templates.
+# * {Haml::Template} interfaces with web frameworks (Rails in particular).
+# * {Haml::Error} is raised when Haml encounters an error.
+# * {Haml::HTML} handles conversion of HTML to Haml.
+#
+# Also see the {file:HAML_REFERENCE.md full Haml reference}.
+module Haml
+ extend Haml::Version
+
+ # A string representing the version of Haml.
+ # A more fine-grained representation is available from Haml.version.
+ VERSION = version[:string] unless defined?(Haml::VERSION)
+
+ # Initializes Haml for Rails.
+ #
+ # This method is called by `init.rb`,
+ # which is run by Rails on startup.
+ # We use it rather than putting stuff straight into `init.rb`
+ # so we can change the initialization behavior
+ # without modifying the file itself.
+ #
+ # @param binding [Binding] The context of the `init.rb` file.
+ # This isn't actually used;
+ # it's just passed in in case it needs to be used in the future
+ def self.init_rails(binding)
+ # No &method here for Rails 2.1 compatibility
+ %w[haml/template sass sass/plugin].each {|f| require f}
+ end
+end
+
+require 'haml/util'
+require 'haml/engine'
View
302 vendor/haml-2.2.1/lib/haml/buffer.rb
@@ -0,0 +1,302 @@
+module Haml
+ # This class is used only internally. It holds the buffer of HTML that
+ # is eventually output as the resulting document.
+ # It's called from within the precompiled code,
+ # and helps reduce the amount of processing done within `instance_eval`ed code.
+ class Buffer
+ include Haml::Helpers
+ include Haml::Util
+
+ # The string that holds the compiled HTML. This is aliased as
+ # `_erbout` for compatibility with ERB-specific code.
+ #
+ # @return [String]
+ attr_accessor :buffer
+
+ # The options hash passed in from {Haml::Engine}.
+ #
+ # @return [Hash<String, Object>]
+ # @see Haml::Engine#options_for_buffer
+ attr_accessor :options
+
+ # The {Buffer} for the enclosing Haml document.
+ # This is set for partials and similar sorts of nested templates.
+ # It's `nil` at the top level (see \{#toplevel?}).
+ #
+ # @return [Buffer]
+ attr_accessor :upper
+
+ # nil if there's no capture_haml block running,
+ # and the position at which it's beginning the capture if there is one.
+ #
+ # @return [Fixnum, nil]
+ attr_accessor :capture_position
+
+ # @return [Boolean]
+ # @see #active?
+ attr_writer :active
+
+ # @return [Boolean] Whether or not the format is XHTML
+ def xhtml?
+ not html?
+ end
+
+ # @return [Boolean] Whether or not the format is any flavor of HTML
+ def html?
+ html4? or html5?
+ end
+
+ # @return [Boolean] Whether or not the format is HTML4
+ def html4?
+ @options[:format] == :html4
+ end
+
+ # @return [Boolean] Whether or not the format is HTML5.
+ def html5?
+ @options[:format] == :html5
+ end
+
+ # @return [Boolean] Whether or not this buffer is a top-level template,
+ # as opposed to a nested partial
+ def toplevel?
+ upper.nil?
+ end
+
+ # Whether or not this buffer is currently being used to render a Haml template.
+ # Returns `false` if a subtemplate is being rendered,
+ # even if it's a subtemplate of this buffer's template.
+ #
+ # @return [Boolean]
+ def active?
+ @active
+ end
+
+ # @return [Fixnum] The current indentation level of the document
+ def tabulation
+ @real_tabs + @tabulation
+ end
+
+ # Sets the current tabulation of the document.
+ #
+ # @param val [Fixnum] The new tabulation
+ def tabulation=(val)
+ val = val - @real_tabs
+ @tabulation = val > -1 ? val : 0
+ end
+
+ # @param upper [Buffer] The parent buffer
+ # @param options [Hash<Symbol, Object>] An options hash.
+ # See {Haml::Engine#options\_for\_buffer}
+ def initialize(upper = nil, options = {})
+ @active = true
+ @upper = upper
+ @options = options
+ @buffer = ruby1_8? ? "" : "".encode(Encoding.find(options[:encoding]))
+ @tabulation = 0
+
+ # The number of tabs that Engine thinks we should have
+ # @real_tabs + @tabulation is the number of tabs actually output
+ @real_tabs = 0
+ end
+
+ # Appends text to the buffer, properly tabulated.
+ # Also modifies the document's indentation.
+ #
+ # @param text [String] The text to append
+ # @param tab_change [Fixnum] The number of tabs by which to increase
+ # or decrease the document's indentation
+ # @param dont_tab_up [Boolean] If true, don't indent the first line of `text`
+ def push_text(text, tab_change, dont_tab_up)
+ if @tabulation > 0
+ # Have to push every line in by the extra user set tabulation.
+ # Don't push lines with just whitespace, though,
+ # because that screws up precompiled indentation.
+ text.gsub!(/^(?!\s+$)/m, tabs)
+ text.sub!(tabs, '') if dont_tab_up
+ end
+
+ @buffer << text
+ @real_tabs += tab_change
+ end
+
+ # Modifies the indentation of the document.
+ #
+ # @param tab_change [Fixnum] The number of tabs by which to increase
+ # or decrease the document's indentation
+ def adjust_tabs(tab_change)
+ @real_tabs += tab_change
+ end
+
+ Haml::Util.def_static_method(self, :format_script, [:result],
+ :preserve_script, :in_tag, :preserve_tag, :escape_html,
+ :nuke_inner_whitespace, :interpolated, :ugly, <<RUBY)
+ <% unless ugly %>
+ # If we're interpolated,
+ # then the custom tabulation is handled in #push_text.
+ # The easiest way to avoid it here is to reset @tabulation.
+ <% if interpolated %>
+ old_tabulation = @tabulation
+ @tabulation = 0
+ <% end %>
+
+ tabulation = @real_tabs
+ result = result.to_s.<% if nuke_inner_whitespace %>strip<% else %>rstrip<% end %>
+ <% else %>
+ result = result.to_s<% if nuke_inner_whitespace %>.strip<% end %>
+ <% end %>
+
+ <% if escape_html %> result = html_escape(result) <% end %>
+
+ <% if preserve_tag %>
+ result = Haml::Helpers.preserve(result)
+ <% elsif preserve_script %>
+ result = Haml::Helpers.find_and_preserve(result, options[:preserve])
+ <% end %>
+
+ <% if ugly %>
+ return result
+ <% else %>
+
+ has_newline = result.include?("\\n")
+ <% if in_tag && !nuke_inner_whitespace %>
+ <% unless preserve_tag %> if !has_newline <% end %>
+ @real_tabs -= 1
+ <% if interpolated %> @tabulation = old_tabulation <% end %>
+ return result
+ <% unless preserve_tag %> end <% end %>
+ <% end %>
+
+ # Precompiled tabulation may be wrong
+ <% if !interpolated && !in_tag %>
+ result = tabs + result if @tabulation > 0
+ <% end %>
+
+ if has_newline
+ result = result.gsub "\\n", "\\n" + tabs(tabulation)
+
+ # Add tabulation if it wasn't precompiled
+ <% if in_tag && !nuke_inner_whitespace %> result = tabs(tabulation) + result <% end %>
+ end
+
+ <% if in_tag && !nuke_inner_whitespace %>
+ result = "\\n\#{result}\\n\#{tabs(tabulation-1)}"
+ @real_tabs -= 1
+ <% end %>
+ <% if interpolated %> @tabulation = old_tabulation <% end %>
+ result
+ <% end %>
+RUBY
+
+ # Takes the various information about the opening tag for an element,
+ # formats it, and appends it to the buffer.
+ def open_tag(name, self_closing, try_one_line, preserve_tag, escape_html, class_id,
+ nuke_outer_whitespace, nuke_inner_whitespace, obj_ref, content, *attributes_hashes)
+ tabulation = @real_tabs
+
+ attributes = class_id
+ attributes_hashes.each do |old|
+ self.class.merge_attrs(attributes, to_hash(old.map {|k, v| [k.to_s, v]}))
+ end
+ self.class.merge_attrs(attributes, parse_object_ref(obj_ref)) if obj_ref
+
+ if self_closing && xhtml?
+ str = " />" + (nuke_outer_whitespace ? "" : "\n")
+ else
+ str = ">" + ((if self_closing && html?
+ nuke_outer_whitespace
+ else
+ try_one_line || preserve_tag || nuke_inner_whitespace
+ end) ? "" : "\n")
+ end
+
+ attributes = Precompiler.build_attributes(html?, @options[:attr_wrapper], attributes)
+ @buffer << "#{nuke_outer_whitespace || @options[:ugly] ? '' : tabs(tabulation)}<#{name}#{attributes}#{str}"
+
+ if content
+ @buffer << "#{content}</#{name}>" << (nuke_outer_whitespace ? "" : "\n")
+ return
+ end
+
+ @real_tabs += 1 unless self_closing || nuke_inner_whitespace
+ end
+
+ # Remove the whitespace from the right side of the buffer string.
+ # Doesn't do anything if we're at the beginning of a capture_haml block.
+ def rstrip!
+ if capture_position.nil?
+ buffer.rstrip!
+ return
+ end
+
+ buffer << buffer.slice!(capture_position..-1).rstrip
+ end
+
+ # Merges two attribute hashes.
+ # This is the same as `to.merge!(from)`,
+ # except that it merges id and class attributes.
+ #
+ # ids are concatenated with `"_"`,
+ # and classes are concatenated with `" "`.
+ #
+ # Destructively modifies both `to` and `from`.
+ #
+ # @param to [Hash<String, String>] The attribute hash to merge into
+ # @param from [Hash<String, String>] The attribute hash to merge from
+ # @return [Hash<String, String>] `to`, after being merged
+ def self.merge_attrs(to, from)
+ if to['id'] && from['id']
+ to['id'] << '_' << from.delete('id')
+ elsif to['id'] || from['id']
+ from['id'] ||= to['id']
+ end
+
+ if to['class'] && from['class']
+ # Make sure we don't duplicate class names
+ from['class'] = (from['class'].split(' ') | to['class'].split(' ')).sort.join(' ')
+ elsif to['class'] || from['class']
+ from['class'] ||= to['class']
+ end
+
+ to.merge!(from)
+ end
+
+ private
+
+ @@tab_cache = {}
+ # Gets `count` tabs. Mostly for internal use.
+ def tabs(count = 0)
+ tabs = [count + @tabulation, 0].max
+ @@tab_cache[tabs] ||= ' ' * tabs
+ end
+
+ # Takes an array of objects and uses the class and id of the first
+ # one to create an attributes hash.
+ # The second object, if present, is used as a prefix,
+ # just like you can do with `dom_id()` and `dom_class()` in Rails
+ def parse_object_ref(ref)
+ prefix = ref[1]
+ ref = ref[0]
+ # Let's make sure the value isn't nil. If it is, return the default Hash.
+ return {} if ref.nil?
+ class_name = underscore(ref.class)
+ id = "#{class_name}_#{ref.id || 'new'}"
+ if prefix
+ class_name = "#{ prefix }_#{ class_name}"
+ id = "#{ prefix }_#{ id }"
+ end
+
+ {'id' => id, 'class' => class_name}
+ end
+
+ # Changes a word from camel case to underscores.
+ # Based on the method of the same name in Rails' Inflector,
+ # but copied here so it'll run properly without Rails.
+ def underscore(camel_cased_word)
+ camel_cased_word.to_s.gsub(/::/, '_').
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ tr("-", "_").
+ downcase
+ end
+ end
+end
View
297 vendor/haml-2.2.1/lib/haml/engine.rb
@@ -0,0 +1,297 @@
+require 'haml/helpers'
+require 'haml/buffer'
+require 'haml/precompiler'
+require 'haml/filters'
+require 'haml/error'
+
+module Haml
+ # This is the frontend for using Haml programmatically.
+ # It can be directly used by the user by creating a
+ # new instance and calling \{#render} to render the template.
+ # For example:
+ #
+ # template = File.read('templates/really_cool_template.haml')
+ # haml_engine = Haml::Engine.new(template)
+ # output = haml_engine.render
+ # puts output
+ class Engine
+ include Precompiler
+
+ # The options hash.
+ # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
+ #
+ # @return [Hash<Symbol, Object>]
+ attr_accessor :options
+
+ # The indentation used in the Haml document,
+ # or `nil` if the indentation is ambiguous
+ # (for example, for a single-level document).
+ #
+ # @return [String]
+ attr_accessor :indentation
+
+ # @return [Boolean] Whether or not the format is XHTML.
+ def xhtml?
+ not html?
+ end
+
+ # @return [Boolean] Whether or not the format is any flavor of HTML.
+ def html?
+ html4? or html5?
+ end
+
+ # @return [Boolean] Whether or not the format is HTML4.
+ def html4?
+ @options[:format] == :html4
+ end
+
+ # @return [Boolean] Whether or not the format is HTML5.
+ def html5?
+ @options[:format] == :html5
+ end
+
+ # The source code that is evaluated to produce the Haml document.
+ #
+ # In Ruby 1.9, this is automatically converted to the correct encoding
+ # (see {file:HAML_REFERENCE.md#encoding-option the `:encoding` option}).
+ #
+ # @return [String]
+ def precompiled
+ return @precompiled if ruby1_8?
+ return @precompiled.encode(Encoding.find(@options[:encoding]))
+ end
+
+ # Precompiles the Haml template.
+ #
+ # @param template [String] The Haml template
+ # @param options [Hash<Symbol, Object>] An options hash;
+ # see {file:HAML_REFERENCE.md#haml_options the Haml options documentation}
+ # @raise [Haml::Error] if there's a Haml syntax error in the template
+ def initialize(template, options = {})
+ @options = {
+ :suppress_eval => false,
+ :attr_wrapper => "'",
+
+ # Don't forget to update the docs in lib/haml.rb if you update these
+ :autoclose => %w[meta img link br hr input area param col base],
+ :preserve => %w[textarea pre],
+
+ :filename => '(haml)',
+ :line => 1,
+ :ugly => false,
+ :format => :xhtml,
+ :escape_html => false,
+ }
+ unless ruby1_8?
+ @options[:encoding] = Encoding.default_internal || "utf-8"
+ end
+ @options.merge! options
+ @index = 0
+
+ unless [:xhtml, :html4, :html5].include?(@options[:format])
+ raise Haml::Error, "Invalid format #{@options[:format].inspect}"
+ end
+
+ if @options[:encoding] && @options[:encoding].is_a?(Encoding)
+ @options[:encoding] = @options[:encoding].name
+ end
+
+ # :eod is a special end-of-document marker
+ @template = (template.rstrip).split(/\r\n|\r|\n/) + [:eod, :eod]
+ @template_index = 0
+ @to_close_stack = []
+ @output_tabs = 0
+ @template_tabs = 0
+ @flat = false
+ @newlines = 0
+ @precompiled = ''
+ @to_merge = []
+ @tab_change = 0
+ @temp_count = 0
+
+ precompile
+ rescue Haml::Error => e
+ e.backtrace.unshift "#{@options[:filename]}:#{(e.line ? e.line + 1 : @index) + @options[:line] - 1}" if @index
+ raise
+ end
+
+ # Processes the template and returns the result as a string.
+ #
+ # `scope` is the context in which the template is evaluated.
+ # If it's a `Binding` or `Proc` object,
+ # Haml uses it as the second argument to `Kernel#eval`;
+ # otherwise, Haml just uses its `#instance_eval` context.
+ #
+ # Note that Haml modifies the evaluation context
+ # (either the scope object or the `self` object of the scope binding).
+ # It extends {Haml::Helpers}, and various instance variables are set
+ # (all prefixed with `haml_`).
+ # For example:
+ #
+ # s = "foobar"
+ # Haml::Engine.new("%p= upcase").render(s) #=> "<p>FOOBAR</p>"
+ #
+ # # s now extends Haml::Helpers
+ # s.responds_to?(:html_attrs) #=> true
+ #
+ # `locals` is a hash of local variables to make available to the template.
+ # For example:
+ #
+ # Haml::Engine.new("%p= foo").render(Object.new, :foo => "Hello, world!") #=> "<p>Hello, world!</p>"
+ #
+ # If a block is passed to render,
+ # that block is run when `yield` is called
+ # within the template.
+ #
+ # Due to some Ruby quirks,
+ # if `scope` is a `Binding` or `Proc` object and a block is given,
+ # the evaluation context may not be quite what the user expects.
+ # In particular, it's equivalent to passing `eval("self", scope)` as `scope`.
+ # This won't have an effect in most cases,
+ # but if you're relying on local variables defined in the context of `scope`,