radiant 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

Files changed (208) hide show
  1. data/CHANGELOG +15 -0
  2. data/CONTRIBUTORS +8 -0
  3. data/app/controllers/admin/page_controller.rb +1 -11
  4. data/app/controllers/admin/welcome_controller.rb +5 -6
  5. data/app/controllers/application.rb +2 -0
  6. data/app/controllers/site_controller.rb +1 -0
  7. data/app/helpers/admin/page_helper.rb +36 -0
  8. data/app/helpers/admin/regions_helper.rb +28 -0
  9. data/app/helpers/admin/user_helper.rb +6 -0
  10. data/app/helpers/application_helper.rb +2 -1
  11. data/app/models/user.rb +7 -8
  12. data/app/views/admin/extension/index.html.haml +28 -0
  13. data/app/views/admin/layout/edit.html.haml +44 -0
  14. data/app/views/admin/layout/index.html.haml +25 -0
  15. data/app/views/admin/layout/remove.html.haml +16 -0
  16. data/app/views/admin/page/_meta_row.html.haml +6 -0
  17. data/app/views/admin/page/_node.html.haml +25 -0
  18. data/app/views/admin/page/_part.html.haml +17 -0
  19. data/app/views/admin/page/_tag_reference.html.haml +3 -0
  20. data/app/views/admin/page/children.html.haml +2 -0
  21. data/app/views/admin/page/edit.html.haml +114 -0
  22. data/app/views/admin/page/index.html.haml +28 -0
  23. data/app/views/admin/page/remove.html.haml +20 -0
  24. data/app/views/admin/snippet/edit.html.haml +36 -0
  25. data/app/views/admin/snippet/index.html.haml +20 -0
  26. data/app/views/admin/snippet/remove.html.haml +19 -0
  27. data/app/views/admin/user/edit.html.haml +80 -0
  28. data/app/views/admin/user/index.html.haml +23 -0
  29. data/app/views/admin/user/preferences.html.haml +28 -0
  30. data/app/views/admin/user/remove.html.haml +18 -0
  31. data/app/views/admin/welcome/login.html.haml +44 -0
  32. data/app/views/layouts/application.html.haml +54 -0
  33. data/app/views/site/not_found.html.haml +3 -0
  34. data/db/migrate/019_add_salt_to_users.rb +11 -0
  35. data/db/schema.rb +2 -1
  36. data/lib/login_system.rb +1 -0
  37. data/lib/radiant.rb +1 -1
  38. data/lib/radiant/admin_ui.rb +65 -0
  39. data/lib/radiant/admin_ui/region_partials.rb +18 -0
  40. data/lib/radiant/admin_ui/region_set.rb +35 -0
  41. data/lib/tasks/extensions.rake +33 -0
  42. data/public/javascripts/admin/admin.js +8 -2
  43. data/public/javascripts/admin/sitemap.js +2 -1
  44. data/public/stylesheets/admin/main.css +4 -0
  45. data/spec/controllers/admin/abstract_model_controller_spec.rb +2 -0
  46. data/spec/controllers/admin/page_controller_spec.rb +3 -28
  47. data/spec/controllers/admin/user_controller_spec.rb +1 -1
  48. data/spec/controllers/admin/welcome_controller_spec.rb +26 -0
  49. data/spec/helpers/admin/page_helper_spec.rb +4 -0
  50. data/spec/helpers/admin/regions_helper_spec.rb +47 -0
  51. data/spec/helpers/admin/user_helper_spec.rb +7 -0
  52. data/spec/helpers/application_helper_spec.rb +7 -3
  53. data/spec/lib/login_system_spec.rb +5 -0
  54. data/spec/lib/radiant/admin_ui/region_partials_spec.rb +35 -0
  55. data/spec/lib/radiant/admin_ui/region_set_spec.rb +61 -0
  56. data/spec/lib/radiant/admin_ui_spec.rb +74 -18
  57. data/spec/models/user_spec.rb +11 -4
  58. data/spec/scenarios/users_scenario.rb +2 -2
  59. data/vendor/plugins/haml/MIT-LICENSE +20 -0
  60. data/vendor/plugins/haml/README.rdoc +319 -0
  61. data/vendor/plugins/haml/Rakefile +158 -0
  62. data/vendor/plugins/haml/TODO +9 -0
  63. data/vendor/plugins/haml/VERSION +1 -0
  64. data/vendor/plugins/haml/bin/css2sass +7 -0
  65. data/vendor/plugins/haml/bin/haml +8 -0
  66. data/vendor/plugins/haml/bin/html2haml +7 -0
  67. data/vendor/plugins/haml/bin/sass +8 -0
  68. data/vendor/plugins/haml/extra/haml-mode.el +328 -0
  69. data/vendor/plugins/haml/extra/sass-mode.el +88 -0
  70. data/vendor/plugins/haml/init.rb +2 -0
  71. data/vendor/plugins/haml/lib/haml.rb +977 -0
  72. data/vendor/plugins/haml/lib/haml/buffer.rb +229 -0
  73. data/vendor/plugins/haml/lib/haml/engine.rb +274 -0
  74. data/vendor/plugins/haml/lib/haml/error.rb +23 -0
  75. data/vendor/plugins/haml/lib/haml/exec.rb +347 -0
  76. data/vendor/plugins/haml/lib/haml/filters.rb +249 -0
  77. data/vendor/plugins/haml/lib/haml/helpers.rb +413 -0
  78. data/vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb +45 -0
  79. data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +122 -0
  80. data/vendor/plugins/haml/lib/haml/html.rb +188 -0
  81. data/vendor/plugins/haml/lib/haml/precompiler.rb +757 -0
  82. data/vendor/plugins/haml/lib/haml/template.rb +43 -0
  83. data/vendor/plugins/haml/lib/haml/template/patch.rb +58 -0
  84. data/vendor/plugins/haml/lib/haml/template/plugin.rb +72 -0
  85. data/vendor/plugins/haml/lib/sass.rb +833 -0
  86. data/vendor/plugins/haml/lib/sass/constant.rb +245 -0
  87. data/vendor/plugins/haml/lib/sass/constant/color.rb +101 -0
  88. data/vendor/plugins/haml/lib/sass/constant/literal.rb +53 -0
  89. data/vendor/plugins/haml/lib/sass/constant/number.rb +87 -0
  90. data/vendor/plugins/haml/lib/sass/constant/operation.rb +30 -0
  91. data/vendor/plugins/haml/lib/sass/constant/string.rb +22 -0
  92. data/vendor/plugins/haml/lib/sass/css.rb +378 -0
  93. data/vendor/plugins/haml/lib/sass/engine.rb +459 -0
  94. data/vendor/plugins/haml/lib/sass/error.rb +35 -0
  95. data/vendor/plugins/haml/lib/sass/plugin.rb +165 -0
  96. data/vendor/plugins/haml/lib/sass/plugin/merb.rb +56 -0
  97. data/vendor/plugins/haml/lib/sass/plugin/rails.rb +24 -0
  98. data/vendor/plugins/haml/lib/sass/tree/attr_node.rb +53 -0
  99. data/vendor/plugins/haml/lib/sass/tree/comment_node.rb +20 -0
  100. data/vendor/plugins/haml/lib/sass/tree/directive_node.rb +46 -0
  101. data/vendor/plugins/haml/lib/sass/tree/node.rb +42 -0
  102. data/vendor/plugins/haml/lib/sass/tree/rule_node.rb +89 -0
  103. data/vendor/plugins/haml/lib/sass/tree/value_node.rb +16 -0
  104. data/vendor/plugins/haml/test/benchmark.rb +82 -0
  105. data/vendor/plugins/haml/test/haml/engine_test.rb +587 -0
  106. data/vendor/plugins/haml/test/haml/helper_test.rb +187 -0
  107. data/vendor/plugins/haml/test/haml/html2haml_test.rb +60 -0
  108. data/vendor/plugins/haml/test/haml/markaby/standard.mab +52 -0
  109. data/vendor/plugins/haml/test/haml/mocks/article.rb +6 -0
  110. data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +16 -0
  111. data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +11 -0
  112. data/vendor/plugins/haml/test/haml/results/filters.xhtml +82 -0
  113. data/vendor/plugins/haml/test/haml/results/helpers.xhtml +94 -0
  114. data/vendor/plugins/haml/test/haml/results/helpful.xhtml +10 -0
  115. data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +64 -0
  116. data/vendor/plugins/haml/test/haml/results/list.xhtml +12 -0
  117. data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +22 -0
  118. data/vendor/plugins/haml/test/haml/results/partials.xhtml +21 -0
  119. data/vendor/plugins/haml/test/haml/results/silent_script.xhtml +74 -0
  120. data/vendor/plugins/haml/test/haml/results/standard.xhtml +42 -0
  121. data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +28 -0
  122. data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +7 -0
  123. data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +94 -0
  124. data/vendor/plugins/haml/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  125. data/vendor/plugins/haml/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  126. data/vendor/plugins/haml/test/haml/rhtml/action_view.rhtml +62 -0
  127. data/vendor/plugins/haml/test/haml/rhtml/standard.rhtml +54 -0
  128. data/vendor/plugins/haml/test/haml/template_test.rb +168 -0
  129. data/vendor/plugins/haml/test/haml/templates/_av_partial_1.haml +9 -0
  130. data/vendor/plugins/haml/test/haml/templates/_av_partial_2.haml +5 -0
  131. data/vendor/plugins/haml/test/haml/templates/_partial.haml +8 -0
  132. data/vendor/plugins/haml/test/haml/templates/_text_area.haml +3 -0
  133. data/vendor/plugins/haml/test/haml/templates/action_view.haml +47 -0
  134. data/vendor/plugins/haml/test/haml/templates/breakage.haml +8 -0
  135. data/vendor/plugins/haml/test/haml/templates/content_for_layout.haml +10 -0
  136. data/vendor/plugins/haml/test/haml/templates/eval_suppressed.haml +11 -0
  137. data/vendor/plugins/haml/test/haml/templates/filters.haml +81 -0
  138. data/vendor/plugins/haml/test/haml/templates/helpers.haml +69 -0
  139. data/vendor/plugins/haml/test/haml/templates/helpful.haml +11 -0
  140. data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +77 -0
  141. data/vendor/plugins/haml/test/haml/templates/list.haml +12 -0
  142. data/vendor/plugins/haml/test/haml/templates/original_engine.haml +17 -0
  143. data/vendor/plugins/haml/test/haml/templates/partialize.haml +1 -0
  144. data/vendor/plugins/haml/test/haml/templates/partials.haml +12 -0
  145. data/vendor/plugins/haml/test/haml/templates/silent_script.haml +40 -0
  146. data/vendor/plugins/haml/test/haml/templates/standard.haml +42 -0
  147. data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +24 -0
  148. data/vendor/plugins/haml/test/haml/templates/very_basic.haml +4 -0
  149. data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +87 -0
  150. data/vendor/plugins/haml/test/haml/test_helper.rb +15 -0
  151. data/vendor/plugins/haml/test/profile.rb +65 -0
  152. data/vendor/plugins/haml/test/sass/engine_test.rb +276 -0
  153. data/vendor/plugins/haml/test/sass/plugin_test.rb +159 -0
  154. data/vendor/plugins/haml/test/sass/results/alt.css +4 -0
  155. data/vendor/plugins/haml/test/sass/results/basic.css +9 -0
  156. data/vendor/plugins/haml/test/sass/results/compact.css +5 -0
  157. data/vendor/plugins/haml/test/sass/results/complex.css +87 -0
  158. data/vendor/plugins/haml/test/sass/results/compressed.css +1 -0
  159. data/vendor/plugins/haml/test/sass/results/constants.css +14 -0
  160. data/vendor/plugins/haml/test/sass/results/expanded.css +19 -0
  161. data/vendor/plugins/haml/test/sass/results/import.css +29 -0
  162. data/vendor/plugins/haml/test/sass/results/mixins.css +95 -0
  163. data/vendor/plugins/haml/test/sass/results/multiline.css +24 -0
  164. data/vendor/plugins/haml/test/sass/results/nested.css +22 -0
  165. data/vendor/plugins/haml/test/sass/results/parent_ref.css +13 -0
  166. data/vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  167. data/vendor/plugins/haml/test/sass/results/subdir/subdir.css +1 -0
  168. data/vendor/plugins/haml/test/sass/templates/_partial.sass +2 -0
  169. data/vendor/plugins/haml/test/sass/templates/alt.sass +16 -0
  170. data/vendor/plugins/haml/test/sass/templates/basic.sass +23 -0
  171. data/vendor/plugins/haml/test/sass/templates/bork.sass +2 -0
  172. data/vendor/plugins/haml/test/sass/templates/bork2.sass +2 -0
  173. data/vendor/plugins/haml/test/sass/templates/compact.sass +17 -0
  174. data/vendor/plugins/haml/test/sass/templates/complex.sass +310 -0
  175. data/vendor/plugins/haml/test/sass/templates/compressed.sass +15 -0
  176. data/vendor/plugins/haml/test/sass/templates/constants.sass +97 -0
  177. data/vendor/plugins/haml/test/sass/templates/expanded.sass +17 -0
  178. data/vendor/plugins/haml/test/sass/templates/import.sass +11 -0
  179. data/vendor/plugins/haml/test/sass/templates/importee.sass +14 -0
  180. data/vendor/plugins/haml/test/sass/templates/mixins.sass +76 -0
  181. data/vendor/plugins/haml/test/sass/templates/multiline.sass +20 -0
  182. data/vendor/plugins/haml/test/sass/templates/nested.sass +25 -0
  183. data/vendor/plugins/haml/test/sass/templates/parent_ref.sass +25 -0
  184. data/vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  185. data/vendor/plugins/haml/test/sass/templates/subdir/subdir.sass +6 -0
  186. metadata +185 -24
  187. data/app/views/admin/extension/index.html.erb +0 -40
  188. data/app/views/admin/layout/edit.html.erb +0 -39
  189. data/app/views/admin/layout/index.html.erb +0 -38
  190. data/app/views/admin/layout/remove.html.erb +0 -17
  191. data/app/views/admin/page/_meta_row.html.erb +0 -4
  192. data/app/views/admin/page/_node.html.erb +0 -28
  193. data/app/views/admin/page/_part.html.erb +0 -13
  194. data/app/views/admin/page/_tag_reference.html.erb +0 -4
  195. data/app/views/admin/page/children.html.erb +0 -4
  196. data/app/views/admin/page/edit.html.erb +0 -140
  197. data/app/views/admin/page/index.html.erb +0 -31
  198. data/app/views/admin/page/remove.html.erb +0 -14
  199. data/app/views/admin/snippet/edit.html.erb +0 -29
  200. data/app/views/admin/snippet/index.html.erb +0 -36
  201. data/app/views/admin/snippet/remove.html.erb +0 -16
  202. data/app/views/admin/user/edit.html.erb +0 -54
  203. data/app/views/admin/user/index.html.erb +0 -43
  204. data/app/views/admin/user/preferences.html.erb +0 -29
  205. data/app/views/admin/user/remove.html.erb +0 -16
  206. data/app/views/admin/welcome/login.html.erb +0 -51
  207. data/app/views/layouts/application.html.erb +0 -83
  208. data/app/views/site/not_found.html.erb +0 -3
@@ -0,0 +1,88 @@
1
+ ;;; sass-mode.el -- Major mode for editing Sass files
2
+ ;;; Written by Nathan Weizenbaum
3
+
4
+ ;;; Because Sass's indentation schema is similar
5
+ ;;; to that of YAML and Python, many indentation-related
6
+ ;;; functions are similar to those in yaml-mode and python-mode.
7
+
8
+ ;;; To install, save this somewhere and add the following to your .emacs file:
9
+ ;;;
10
+ ;;; (add-to-list 'load-path "/path/to/sass-mode.el")
11
+ ;;; (require 'sass-mode nil 't)
12
+ ;;; (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
13
+ ;;;
14
+
15
+ ;;; Code:
16
+
17
+ (require 'haml-mode)
18
+
19
+ ;; User definable variables
20
+
21
+ (defgroup sass nil
22
+ "Support for the Sass template language."
23
+ :group 'languages
24
+ :prefix "sass-")
25
+
26
+ (defcustom sass-mode-hook nil
27
+ "Hook run when entering Sass mode."
28
+ :type 'hook
29
+ :group 'sass)
30
+
31
+ (defcustom sass-indent-offset 2
32
+ "Amount of offset per level of indentation."
33
+ :type 'integer
34
+ :group 'sass)
35
+
36
+ (defvar sass-non-block-openers
37
+ '("^ *:[^ \t]+[ \t]+[^ \t]"
38
+ "^ *[^ \t:]+[ \t]*[=:][ \t]*[^ \t]")
39
+ "A list of regexps that match lines of Sass that couldn't have
40
+ text nested beneath them.")
41
+
42
+ ;; Font lock
43
+
44
+ (defconst sass-font-lock-keywords
45
+ '(("^ *\\(\t\\)" 1 'haml-tab-face)
46
+ ("^@.*" 0 font-lock-constant-face)
47
+ ("\\(\'[^']*'\\)" 1 font-lock-string-face append)
48
+ ("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
49
+ ("\\(#[0-9a-fA-F]\\{3\\}\\{1,2\\}\\>\\)" 1 font-lock-string-face append)
50
+ ("\\(:[A-Za-z-]+\\|[A-Za-z-]+:\\)" 0 font-lock-constant-face append)
51
+ ("![a-z0-9_-]+" 0 font-lock-variable-name-face append)
52
+ ("^ *\\(/[/*].*\\)$" 1 font-lock-comment-face append)
53
+ ("\\(?:^\\|,\\) *\\(#[a-z0-9_-]+\/?\\)" 1 font-lock-keyword-face)
54
+ ("\\(?:^\\|,\\) *\\(\\.[a-z0-9_-]+\/?\\)" 1 font-lock-type-face)
55
+ ("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face)
56
+ ("\\([=]\\)" 0 font-lock-preprocessor-face prepend)
57
+ ("\\(?:^\\|,\\) *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face)
58
+ ("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
59
+ ("\\(?:^\\|,\\) *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
60
+ ("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
61
+ ("\\(?:^\\|,\\) *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
62
+ ("\\#[a-z0-9_-]+" nil nil (0 font-lock-keyword-face)))
63
+ ("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
64
+ ("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
65
+ ("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
66
+ ("\\#[a-z0-9_-]+" nil nil (0 font-lock-keyword-face)))))
67
+
68
+ ;; Constants
69
+
70
+ ;; Mode setup
71
+
72
+ (define-derived-mode sass-mode haml-mode "Sass"
73
+ "Major mode for editing Sass files."
74
+ (set (make-local-variable 'haml-indent-function) 'sass-indent-p)
75
+ (set (make-local-variable 'haml-indent-offset) sass-indent-offset)
76
+ (setq font-lock-defaults '(sass-font-lock-keywords nil t)))
77
+
78
+ ;; Indentation
79
+
80
+ (defun sass-indent-p ()
81
+ "Returns true if the current line can have lines nested beneath it."
82
+ (loop for opener in sass-non-block-openers
83
+ unless (looking-at opener) return t
84
+ return nil))
85
+
86
+ ;; Setup/Activation
87
+
88
+ (provide 'sass-mode)
@@ -0,0 +1,2 @@
1
+ require 'haml'
2
+ Haml.init_rails(binding)
@@ -0,0 +1,977 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
3
+
4
+ # = Haml (XHTML Abstraction Markup Language)
5
+ #
6
+ # Haml is a markup language
7
+ # that's used to cleanly and simply describe the XHTML of any web document,
8
+ # without the use of inline code.
9
+ # Haml functions as a replacement
10
+ # for inline page templating systems such as PHP, ERB, and ASP.
11
+ # However, Haml avoids the need for explicitly coding XHTML into the template,
12
+ # because it is actually an abstract description of the XHTML,
13
+ # with some code to generate dynamic content.
14
+ #
15
+ # == Features
16
+ #
17
+ # * Whitespace active
18
+ # * Well-formatted markup
19
+ # * DRY
20
+ # * Follows CSS conventions
21
+ # * Integrates Ruby code
22
+ # * Implements Rails templates with the .haml extension
23
+ #
24
+ # == Using Haml
25
+ #
26
+ # Haml can be used in two ways:
27
+ # as a plugin for Ruby on Rails,
28
+ # and as a standalone Ruby module.
29
+ #
30
+ # Sass can be used in several ways:
31
+ # As a template engine for Ruby on Rails or Merb,
32
+ # or as a standalone engine.
33
+ # The first step for all of these is to install the Haml gem:
34
+ #
35
+ # gem install haml
36
+ #
37
+ # To enable it as a Rails plugin,
38
+ # then run
39
+ #
40
+ # haml --rails path/to/rails/app
41
+ #
42
+ # Haml is enabled in Merb by default,
43
+ # so Merb users don't have to do anything more.
44
+ #
45
+ # Once it's installed, all view files with the ".haml" extension
46
+ # (or ".html.haml" for Merb or edge Rails)
47
+ # will be compiled using Haml.
48
+ #
49
+ # You can access instance variables in Haml templates
50
+ # the same way you do in ERb templates.
51
+ # Helper methods are also available in Haml templates.
52
+ # For example (this example uses Rails, but the principle for Merb is the same):
53
+ #
54
+ # # file: app/controllers/movies_controller.rb
55
+ #
56
+ # class MoviesController < ApplicationController
57
+ # def index
58
+ # @title = "Teen Wolf"
59
+ # end
60
+ # end
61
+ #
62
+ # -# file: app/views/movies/index.haml
63
+ #
64
+ # #content
65
+ # .title
66
+ # %h1= @title
67
+ # = link_to 'Home', home_url
68
+ #
69
+ # may be compiled to:
70
+ #
71
+ # <div id='content'>
72
+ # <div class='title'>
73
+ # <h1>Teen Wolf</h1>
74
+ # <a href='/'>Home</a>
75
+ # </div>
76
+ # </div>
77
+ #
78
+ # === Ruby Module
79
+ #
80
+ # Haml can also be used completely separately from Rails and ActionView.
81
+ # To do this, install the gem with RubyGems:
82
+ #
83
+ # gem install haml
84
+ #
85
+ # You can then use it by including the "haml" gem in Ruby code,
86
+ # and using Haml::Engine like so:
87
+ #
88
+ # engine = Haml::Engine.new("%p Haml code!")
89
+ # engine.render #=> "<p>Haml code!</p>\n"
90
+ #
91
+ # == Characters with meaning to Haml
92
+ #
93
+ # Various characters, when placed at a certain point in a line,
94
+ # instruct Haml to render different types of things.
95
+ #
96
+ # === XHTML Tags
97
+ #
98
+ # These characters render XHTML tags.
99
+ #
100
+ # ==== %
101
+ #
102
+ #
103
+ # The percent character is placed at the beginning of a line.
104
+ # It's followed immediately by the name of an element,
105
+ # then optionally by modifiers (see below), a space,
106
+ # and text to be rendered inside the element.
107
+ # It creates an element in the form of <tt><element></element></tt>.
108
+ # For example:
109
+ #
110
+ # %one
111
+ # %two
112
+ # %three Hey there
113
+ #
114
+ # is compiled to:
115
+ #
116
+ # <one>
117
+ # <two>
118
+ # <three>Hey there</three>
119
+ # </two>
120
+ # </one>
121
+ #
122
+ # Any string is a valid element name;
123
+ # Haml will automatically generate opening and closing tags for any element.
124
+ #
125
+ # ==== {}
126
+ #
127
+ # Brackets represent a Ruby hash
128
+ # that is used for specifying the attributes of an element.
129
+ # It is literally evaluated as a Ruby hash,
130
+ # so logic will work in it and local variables may be used.
131
+ # Quote characters within the attribute
132
+ # will be replaced by appropriate escape sequences.
133
+ # The hash is placed after the tag is defined.
134
+ # For example:
135
+ #
136
+ # %head{ :name => "doc_head" }
137
+ # %script{ 'type' => "text/" + "javascript",
138
+ # :src => "javascripts/script_#{2 + 7}" }
139
+ #
140
+ # is compiled to:
141
+ #
142
+ # <head name="doc_head">
143
+ # <script src='javascripts/script_9' type='text/javascript'>
144
+ # </script>
145
+ # </head>
146
+ #
147
+ # ===== Attribute Methods
148
+ #
149
+ # A Ruby method call that returns a hash
150
+ # can be substituted for the hash contents.
151
+ # For example, Haml::Helpers defines the following method:
152
+ #
153
+ # def html_attrs(lang = 'en-US')
154
+ # {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
155
+ # end
156
+ #
157
+ # This can then be used in Haml, like so:
158
+ #
159
+ # %html{html_attrs('fr-fr')}
160
+ #
161
+ # This is compiled to:
162
+ #
163
+ # <html lang='fr-fr' xml:lang='fr=fr' xmlns='http://www.w3.org/1999/xhtml'>
164
+ # </html>
165
+ #
166
+ # You can use as many such attribute methods as you want
167
+ # by separating them with commas,
168
+ # like a Ruby argument list.
169
+ # All the hashes will me merged together, from left to right.
170
+ # For example, if you defined
171
+ #
172
+ # def hash1
173
+ # {:bread => 'white', :filling => 'peanut butter and jelly'}
174
+ # end
175
+ #
176
+ # def hash2
177
+ # {:bread => 'whole wheat'}
178
+ # end
179
+ #
180
+ # then
181
+ #
182
+ # %sandwich{hash1, hash2, :delicious => true}/
183
+ #
184
+ # would compile to:
185
+ #
186
+ # <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
187
+ #
188
+ # ===== Boolean Attributes
189
+ #
190
+ # Some attributes, such as "checked" for <tt>input</tt> tags or "selected" for <tt>option</tt> tags,
191
+ # are "boolean" in the sense that their values don't matter -
192
+ # it only matters whether or not they're present.
193
+ # In HTML (but not XHTML), these attributes can be written as
194
+ #
195
+ # <input selected>
196
+ #
197
+ # To do this in Haml, just assign a Ruby true value to the attribute:
198
+ #
199
+ # %input{:selected => true}
200
+ #
201
+ # In XHTML, the only valid value for these attributes is the name of the attribute.
202
+ # Thus this will render in XHTML as
203
+ #
204
+ # <input selected="selected">
205
+ #
206
+ # To set these attributes to false, simply assign them to a Ruby false value.
207
+ # In both XHTML and HTML
208
+ #
209
+ # %input{:selected => false}
210
+ #
211
+ # will just render as
212
+ #
213
+ # <input>
214
+ #
215
+ # ==== []
216
+ #
217
+ # Square brackets follow a tag definition and contain a Ruby object
218
+ # that is used to set the class and id of that tag.
219
+ # The class is set to the object's class
220
+ # (transformed to use underlines rather than camel case)
221
+ # and the id is set to the object's class, followed by its id.
222
+ # Because the id of an object is normally an obscure implementation detail,
223
+ # this is most useful for elements that represent instances of Models.
224
+ # Additionally, the second argument (if present) will be used as a prefix for
225
+ # both the id and class attributes.
226
+ # For example:
227
+ #
228
+ # # file: app/controllers/users_controller.rb
229
+ #
230
+ # def show
231
+ # @user = CrazyUser.find(15)
232
+ # end
233
+ #
234
+ # -# file: app/views/users/show.haml
235
+ #
236
+ # %div[@user, :greeting]
237
+ # %bar[290]/
238
+ # Hello!
239
+ #
240
+ # is compiled to:
241
+ #
242
+ # <div class="greeting_crazy_user" id="greeting_crazy_user_15">
243
+ # <bar class="fixnum" id="fixnum_581" />
244
+ # Hello!
245
+ # </div>
246
+ #
247
+ # ==== /
248
+ #
249
+ # The forward slash character, when placed at the end of a tag definition,
250
+ # causes the tag to be self-closed.
251
+ # For example:
252
+ #
253
+ # %br/
254
+ # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
255
+ #
256
+ # is compiled to:
257
+ #
258
+ # <br />
259
+ # <meta http-equiv='Content-Type' content='text/html' />
260
+ #
261
+ # Some tags are automatically closed, as long as they have no content.
262
+ # +meta+, +img+, +link+, +script+, +br+, and +hr+ tags are closed by default.
263
+ # This list can be customized by setting the <tt>:autoclose</tt> option (see below).
264
+ # For example:
265
+ #
266
+ # %br
267
+ # %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
268
+ #
269
+ # is also compiled to:
270
+ #
271
+ # <br />
272
+ # <meta http-equiv='Content-Type' content='text/html' />
273
+ #
274
+ # ==== . and #
275
+ #
276
+ # The period and pound sign are borrowed from CSS.
277
+ # They are used as shortcuts to specify the <tt>class</tt>
278
+ # and <tt>id</tt> attributes of an element, respectively.
279
+ # Multiple class names can be specified in a similar way to CSS,
280
+ # by chaining the class names together with periods.
281
+ # They are placed immediately after the tag and before an attributes hash.
282
+ # For example:
283
+ #
284
+ # %div#things
285
+ # %span#rice Chicken Fried
286
+ # %p.beans{ :food => 'true' } The magical fruit
287
+ # %h1.class.otherclass#id La La La
288
+ #
289
+ # is compiled to:
290
+ #
291
+ # <div id='things'>
292
+ # <span id='rice'>Chicken Fried</span>
293
+ # <p class='beans' food='true'>The magical fruit</p>
294
+ # <h1 class='class otherclass' id='id'>La La La</h1>
295
+ # </div>
296
+ #
297
+ # And,
298
+ #
299
+ # #content
300
+ # .articles
301
+ # .article.title
302
+ # Doogie Howser Comes Out
303
+ # .article.date
304
+ # 2006-11-05
305
+ # .article.entry
306
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
307
+ #
308
+ # is compiled to:
309
+ #
310
+ # <div id="content">
311
+ # <div class="articles">
312
+ # <div class="article title">Doogie Howser Comes Out</div>
313
+ # <div class="article date">2006-11-05</div>
314
+ # <div class="article entry">
315
+ # Neil Patrick Harris would like to dispel any rumors that he is straight
316
+ # </div>
317
+ # </div>
318
+ # </div>
319
+ #
320
+ # ==== Implicit Div Elements
321
+ #
322
+ # Because the div element is used so often, it is the default element.
323
+ # If you only define a class and/or id using the <tt>.</tt> or <tt>#</tt> syntax,
324
+ # a div element is automatically used.
325
+ # For example:
326
+ #
327
+ # #collection
328
+ # .item
329
+ # .description What a cool item!
330
+ #
331
+ # is the same as:
332
+ #
333
+ # %div{:id => collection}
334
+ # %div{:class => 'item'}
335
+ # %div{:class => 'description'} What a cool item!
336
+ #
337
+ # and is compiled to:
338
+ #
339
+ # <div id='collection'>
340
+ # <div class='item'>
341
+ # <div class='description'>What a cool item!</div>
342
+ # </div>
343
+ # </div>
344
+ #
345
+ # ==== =
346
+ #
347
+ # <tt>=</tt> is placed at the end of a tag definition,
348
+ # after class, id, and attribute declarations.
349
+ # It's just a shortcut for inserting Ruby code into an element.
350
+ # It works the same as <tt>=</tt> without a tag:
351
+ # it inserts the result of the Ruby code into the template.
352
+ # However, if the result is short enough,
353
+ # it is displayed entirely on one line.
354
+ # For example:
355
+ #
356
+ # %p= "hello"
357
+ #
358
+ # is not quite the same as:
359
+ #
360
+ # %p
361
+ # = "hello"
362
+ #
363
+ # It's compiled to:
364
+ #
365
+ # <p>hello</p>
366
+ #
367
+ # ==== ~
368
+ #
369
+ # ~ works just like =, except that it runs Haml::Helpers#find_and_preserve on its input.
370
+ # For example,
371
+ #
372
+ # ~ "Foo\n<pre>Bar\nBaz</pre>"
373
+ #
374
+ # is the same as:
375
+ #
376
+ # = find_and_preserve("Foo\n<pre>Bar\nBaz</pre>")
377
+ #
378
+ # and is compiled to:
379
+ #
380
+ # Foo
381
+ # <pre>Bar&#x000A;Baz</pre>
382
+ #
383
+ # See also Whitespace Preservation, below.
384
+ #
385
+ # === XHTML Helpers
386
+ #
387
+ # ==== No Special Character
388
+ #
389
+ # If no special character appears at the beginning of a line,
390
+ # the line is rendered as plain text.
391
+ # For example:
392
+ #
393
+ # %gee
394
+ # %whiz
395
+ # Wow this is cool!
396
+ #
397
+ # is compiled to:
398
+ #
399
+ # <gee>
400
+ # <whiz>
401
+ # Wow this is cool!
402
+ # </whiz>
403
+ # </gee>
404
+ #
405
+ # ==== !!!
406
+ #
407
+ # When describing XHTML documents with Haml,
408
+ # you can have a document type or XML prolog generated automatically
409
+ # by including the characters <tt>!!!</tt>.
410
+ # For example:
411
+ #
412
+ # !!! XML
413
+ # !!!
414
+ # %html
415
+ # %head
416
+ # %title Myspace
417
+ # %body
418
+ # %h1 I am the international space station
419
+ # %p Sign my guestbook
420
+ #
421
+ # is compiled to:
422
+ #
423
+ # <?xml version="1.0" encoding="utf-8" ?>
424
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
425
+ # <html>
426
+ # <head>
427
+ # <title>Myspace</title>
428
+ # </head>
429
+ # <body>
430
+ # <h1>I am the international space station</h1>
431
+ # <p>Sign my guestbook</p>
432
+ # </body>
433
+ # </html>
434
+ #
435
+ # You can also specify the version and type of XHTML after the <tt>!!!</tt>.
436
+ # XHTML 1.0 Strict, Transitional, and Frameset and XHTML 1.1 are supported.
437
+ # The default version is 1.0 and the default type is Transitional.
438
+ # For example:
439
+ #
440
+ # !!! 1.1
441
+ #
442
+ # is compiled to:
443
+ #
444
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
445
+ #
446
+ # and
447
+ #
448
+ # !!! Strict
449
+ #
450
+ # is compiled to:
451
+ #
452
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
453
+ #
454
+ # If you're not using the UTF-8 character set for your document,
455
+ # you can specify which encoding should appear
456
+ # in the XML prolog in a similar way.
457
+ # For example:
458
+ #
459
+ # !!! XML iso-8859-1
460
+ #
461
+ # is compiled to:
462
+ #
463
+ # <?xml version="1.0" encoding="iso-8859-1" ?>
464
+ #
465
+ # ==== /
466
+ #
467
+ # The forward slash character, when placed at the beginning of a line,
468
+ # wraps all text after it in an HTML comment.
469
+ # For example:
470
+ #
471
+ # %peanutbutterjelly
472
+ # / This is the peanutbutterjelly element
473
+ # I like sandwiches!
474
+ #
475
+ # is compiled to:
476
+ #
477
+ # <peanutbutterjelly>
478
+ # <!-- This is the peanutbutterjelly element -->
479
+ # I like sandwiches!
480
+ # </peanutbutterjelly>
481
+ #
482
+ # The forward slash can also wrap indented sections of code. For example:
483
+ #
484
+ # /
485
+ # %p This doesn't render...
486
+ # %div
487
+ # %h1 Because it's commented out!
488
+ #
489
+ # is compiled to:
490
+ #
491
+ # <!--
492
+ # <p>This doesn't render...</p>
493
+ # <div>
494
+ # <h1>Because it's commented out!</h1>
495
+ # </div>
496
+ # -->
497
+ #
498
+ # You can also use Internet Explorer conditional comments
499
+ # (about)[http://www.quirksmode.org/css/condcom.html]
500
+ # by enclosing the condition in square brackets after the <tt>/</tt>.
501
+ # For example:
502
+ #
503
+ # /[if IE]
504
+ # %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
505
+ # %h1 Get Firefox
506
+ #
507
+ # is compiled to:
508
+ #
509
+ # <!--[if IE]>
510
+ # <a href='http://www.mozilla.com/en-US/firefox/'>
511
+ # <h1>Get Firefox</h1>
512
+ # </a>
513
+ # <![endif]-->
514
+ #
515
+ # ==== \
516
+ #
517
+ # The backslash character escapes the first character of a line,
518
+ # allowing use of otherwise interpreted characters as plain text.
519
+ # For example:
520
+ #
521
+ # %title
522
+ # = @title
523
+ # \- MySite
524
+ #
525
+ # is compiled to:
526
+ #
527
+ # <title>
528
+ # MyPage
529
+ # - MySite
530
+ # </title>
531
+ #
532
+ # ==== |
533
+ #
534
+ # The pipe character designates a multiline string.
535
+ # It's placed at the end of a line
536
+ # and means that all following lines that end with <tt>|</tt>
537
+ # will be evaluated as though they were on the same line.
538
+ # For example:
539
+ #
540
+ # %whoo
541
+ # %hoo I think this might get |
542
+ # pretty long so I should |
543
+ # probably make it |
544
+ # multiline so it doesn't |
545
+ # look awful. |
546
+ # %p This is short.
547
+ #
548
+ # is compiled to:
549
+ #
550
+ # <whoo>
551
+ # <hoo>
552
+ # I think this might get pretty long so I should probably make it multiline so it doesn't look awful.
553
+ # </hoo>
554
+ # </whoo>
555
+ #
556
+ # ==== :
557
+ #
558
+ # The colon character designates a filter.
559
+ # This allows you to pass an indented block of text as input
560
+ # to another filtering program and add the result to the output of Haml.
561
+ # The syntax is simply a colon followed by the name of the filter.
562
+ # For example,
563
+ #
564
+ # %p
565
+ # :markdown
566
+ # Textile
567
+ # =======
568
+ #
569
+ # Hello, *World*
570
+ #
571
+ # is compiled to
572
+ #
573
+ # <p>
574
+ # <h1>Textile</h1>
575
+ #
576
+ # <p>Hello, <em>World</em></p>
577
+ # </p>
578
+ #
579
+ # Filters can have Ruby code interpolated, like with ==.
580
+ # For example,
581
+ #
582
+ # - flavor = "raspberry"
583
+ # #content
584
+ # :textile
585
+ # I *really* prefer _#{h flavor}_ jam.
586
+ #
587
+ # is compiled to
588
+ #
589
+ # <div id='content'>
590
+ # <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
591
+ # </div>
592
+ #
593
+ # Haml has the following filters defined:
594
+ #
595
+ # [plain] Does not parse the filtered text.
596
+ # This is useful for large blocks of text without HTML tags,
597
+ # when you don't want lines starting with <tt>.</tt> or <tt>-</tt>
598
+ # to be parsed.
599
+ #
600
+ # [javascript] Surrounds the filtered text with <script> and CDATA tags.
601
+ # Useful for including inline Javascript.
602
+ #
603
+ # [ruby] Parses the filtered text with the normal Ruby interpreter.
604
+ # All output sent to <tt>$stdout</tt>, like with +puts+,
605
+ # is output into the Haml document.
606
+ # Not available if the <tt>suppress_eval</tt> option is set to true.
607
+ # The Ruby code is evaluated in the same context as the Haml template.
608
+ #
609
+ # [preserve] Inserts the filtered text into the template with whitespace preserved.
610
+ # <tt>preserve</tt>d blocks of text aren't indented,
611
+ # and newlines are replaced with the HTML escape code for newlines,
612
+ # to preserve nice-looking output.
613
+ # See also Whitespace Preservation, below.
614
+ #
615
+ # [erb] Parses the filtered text with ERB, like an RHTML template.
616
+ # Not available if the <tt>suppress_eval</tt> option is set to true.
617
+ # Embedded Ruby code is evaluated in the same context as the Haml template.
618
+ #
619
+ # [sass] Parses the filtered text with Sass to produce CSS output.
620
+ #
621
+ # [redcloth] Parses the filtered text with RedCloth (http://whytheluckystiff.net/ruby/redcloth),
622
+ # which uses both Textile and Markdown syntax.
623
+ # Only works if RedCloth is installed.
624
+ #
625
+ # [textile] Parses the filtered text with Textile (http://www.textism.com/tools/textile).
626
+ # Only works if RedCloth is installed.
627
+ #
628
+ # [markdown] Parses the filtered text with Markdown (http://daringfireball.net/projects/markdown).
629
+ # Only works if RedCloth or BlueCloth (http://www.deveiate.org/projects/BlueCloth)
630
+ # is installed
631
+ # (BlueCloth takes precedence if both are installed).
632
+ #
633
+ # You can also define your own filters (see Setting Options, below).
634
+ #
635
+ # === Ruby evaluators
636
+ #
637
+ # ==== =
638
+ #
639
+ # The equals character is followed by Ruby code,
640
+ # which is evaluated and the output inserted into the document as plain text.
641
+ # For example:
642
+ #
643
+ # %p
644
+ # = ['hi', 'there', 'reader!'].join " "
645
+ # = "yo"
646
+ #
647
+ # is compiled to:
648
+ #
649
+ # <p>
650
+ # hi there reader!
651
+ # yo
652
+ # </p>
653
+ #
654
+ # If the <tt>:escape_html</tt> option is set, <tt>=</tt> will sanitize any
655
+ # HTML-sensitive characters generated by the script. For example:
656
+ #
657
+ # = '<script>alert("I\'m evil!");</script>'
658
+ #
659
+ # would be compiled to
660
+ #
661
+ # &lt;script&gt;alert(&quot;I'm evil!&quot;);&lt;/script&gt;
662
+ #
663
+ # ==== -
664
+ #
665
+ # The hyphen character makes the text following it into "silent script":
666
+ # Ruby script that is evaluated, but not output.
667
+ #
668
+ # <b>It is not recommended that you use this widely;
669
+ # almost all processing code and logic should be restricted
670
+ # to the Controller, the Helper, or partials.</b>
671
+ #
672
+ # For example:
673
+ #
674
+ # - foo = "hello"
675
+ # - foo << " there"
676
+ # - foo << " you!"
677
+ # %p= foo
678
+ #
679
+ # is compiled to:
680
+ #
681
+ # <p>
682
+ # hello there you!
683
+ # </p>
684
+ #
685
+ # ==== ==
686
+ #
687
+ # Two equals characters interpolates Ruby code into plain text,
688
+ # similarly to Ruby string interpolation.
689
+ # For example,
690
+ #
691
+ # %p== This is #{h quality} cake!
692
+ #
693
+ # is the same as
694
+ #
695
+ # %p= "This is #{h quality} cake!"
696
+ #
697
+ # and might compile to
698
+ #
699
+ # <p>This is scrumptious cake!</p>
700
+ #
701
+ # Backslashes can be used to escape "#{" strings,
702
+ # but they don't act as escapes anywhere else in the string.
703
+ # For example:
704
+ #
705
+ # %p
706
+ # == \\ Look at \\#{h word} lack of backslash: \#{foo}
707
+ #
708
+ # might compile to
709
+ #
710
+ # <p>
711
+ # \\ Look at \yon lack of backslash: #{foo}
712
+ # </p>
713
+ #
714
+ # ==== &=
715
+ #
716
+ # An ampersand followed by one or two equals characters
717
+ # evaluates Ruby code just like the equals without the ampersand,
718
+ # but sanitizes any HTML-sensitive characters in the result of the code.
719
+ # For example:
720
+ #
721
+ # &= "I like cheese & crackers"
722
+ #
723
+ # compiles to
724
+ #
725
+ # I like cheese &amp; crackers
726
+ #
727
+ # If the <tt>:escape_html</tt> option is set,
728
+ # &= behaves identically to =.
729
+ #
730
+ # ==== !=
731
+ #
732
+ # An exclamation mark followed by one or two equals characters
733
+ # evaluates Ruby code just like the equals would,
734
+ # but never sanitizes the HTML.
735
+ #
736
+ # By default, the single equals doesn't sanitize HTML either.
737
+ # However, if the <tt>:escape_html</tt> option is set, = will sanitize the HTML, but != still won't.
738
+ # For example, if <tt>:escape_html</tt> is set:
739
+ #
740
+ # = "I feel <strong>!"
741
+ # != "I feel <strong>!"
742
+ #
743
+ # compiles to
744
+ #
745
+ # I feel &lt;strong&gt;!
746
+ # I feel <strong>!
747
+ #
748
+ # ===== Blocks
749
+ #
750
+ # Ruby blocks, like XHTML tags, don't need to be explicitly closed in Haml.
751
+ # Rather, they're automatically closed, based on indentation.
752
+ # A block begins whenever the indentation is increased
753
+ # after a silent script command.
754
+ # It ends when the indentation decreases
755
+ # (as long as it's not an +else+ clause or something similar).
756
+ # For example:
757
+ #
758
+ # - (42...47).each do |i|
759
+ # %p= i
760
+ # %p See, I can count!
761
+ #
762
+ # is compiled to:
763
+ #
764
+ # <p>
765
+ # 42
766
+ # </p>
767
+ # <p>
768
+ # 43
769
+ # </p>
770
+ # <p>
771
+ # 44
772
+ # </p>
773
+ # <p>
774
+ # 45
775
+ # </p>
776
+ # <p>
777
+ # 46
778
+ # </p>
779
+ #
780
+ # Another example:
781
+ #
782
+ # %p
783
+ # - case 2
784
+ # - when 1
785
+ # = "1!"
786
+ # - when 2
787
+ # = "2?"
788
+ # - when 3
789
+ # = "3."
790
+ #
791
+ # is compiled to:
792
+ #
793
+ # <p>
794
+ # 2?
795
+ # </p>
796
+ #
797
+ # ==== -#
798
+ #
799
+ # The hyphen followed immediately by the pound sign
800
+ # signifies a silent comment.
801
+ # Any text following this isn't rendered in the resulting document
802
+ # at all.
803
+ #
804
+ # For example:
805
+ #
806
+ # %p foo
807
+ # -# This is a comment
808
+ # %p bar
809
+ #
810
+ # is compiled to:
811
+ #
812
+ # <p>foo</p>
813
+ # <p>bar</p>
814
+ #
815
+ # You can also nest text beneath a silent comment.
816
+ # None of this text will be rendered.
817
+ # For example:
818
+ #
819
+ # %p foo
820
+ # -#
821
+ # This won't be displayed
822
+ # Nor will this
823
+ # %p bar
824
+ #
825
+ # is compiled to:
826
+ #
827
+ # <p>foo</p>
828
+ # <p>bar</p>
829
+ #
830
+ # == Other Useful Things
831
+ #
832
+ # === Whitespace Preservation
833
+ #
834
+ # Sometimes you don't want Haml to indent all your text.
835
+ # For example, tags like +pre+ and +textarea+ are whitespace-sensitive;
836
+ # indenting the text makes them render wrong.
837
+ #
838
+ # Haml deals with this by "preserving" newlines before they're put into the document --
839
+ # converting them to the XHTML whitespace escape code, <tt>&#x000A;</tt>.
840
+ # Then Haml won't try to re-format the indentation.
841
+ #
842
+ # Literal +textarea+ and +pre+ tags automatically preserve their content.
843
+ # Dynamically can't be caught automatically,
844
+ # and so should be passed through Haml::Helpers#find_and_preserve or the <tt>~</tt> command,
845
+ # which has the same effect (see above).
846
+ #
847
+ # Blocks of literal text can be preserved using the :preserve filter (see above).
848
+ #
849
+ # === Helpers
850
+ #
851
+ # Haml offers a bunch of helpers that are useful
852
+ # for doing stuff like preserving whitespace,
853
+ # creating nicely indented output for user-defined helpers,
854
+ # and other useful things.
855
+ # The helpers are all documented in the Haml::Helpers and Haml::Helpers::ActionViewExtensions modules.
856
+ #
857
+ # === Haml Options
858
+ #
859
+ # Options can be set by setting the hash <tt>Haml::Template.options</tt>
860
+ # from <tt>environment.rb</tt> in Rails,
861
+ # or by passing an options hash to Haml::Engine.
862
+ # Available options are:
863
+ #
864
+ # [<tt>:output</tt>] Determines the output format. The default is :xhtml.
865
+ # Other options are :html4 and :html5, which are
866
+ # identical to :xhtml except there are no self-closing tags,
867
+ # XML prolog is ignored and correct DOCTYPEs are generated.
868
+ #
869
+ # [<tt>:escape_html</tt>] Sets whether or not to escape HTML-sensitive characters in script.
870
+ # If this is true, = behaves like &=;
871
+ # otherwise, it behaves like !=.
872
+ # <b>Note that this escapes tag attributes.</b>
873
+ # Defaults to false.
874
+ #
875
+ # [<tt>:suppress_eval</tt>] Whether or not attribute hashes and Ruby scripts
876
+ # designated by <tt>=</tt> or <tt>~</tt> should be
877
+ # evaluated. If this is true, said scripts are
878
+ # rendered as empty strings. Defaults to false.
879
+ #
880
+ # [<tt>:attr_wrapper</tt>] The character that should wrap element attributes.
881
+ # This defaults to <tt>'</tt> (an apostrophe). Characters
882
+ # of this type within the attributes will be escaped
883
+ # (e.g. by replacing them with <tt>&apos;</tt>) if
884
+ # the character is an apostrophe or a quotation mark.
885
+ #
886
+ # [<tt>:filename</tt>] The name of the Haml file being parsed.
887
+ # This is only used as information when exceptions are raised.
888
+ # This is automatically assigned when working through ActionView,
889
+ # so it's really only useful for the user to assign
890
+ # when dealing with Haml programatically.
891
+ #
892
+ # [<tt>:line</tt>] The line offset of the Haml template being parsed.
893
+ # This is useful for inline templates,
894
+ # similar to the last argument to Kernel#eval.
895
+ #
896
+ # [<tt>:filters</tt>] A hash of filters that can be applied to Haml code.
897
+ # The keys are the string names of the filters;
898
+ # the values are references to the classes of the filters.
899
+ # User-defined filters should always have lowercase keys,
900
+ # and should have the interface described in Haml::Filters::Base.
901
+ #
902
+ # [<tt>:autoclose</tt>] A list of tag names that should be automatically self-closed
903
+ # if they have no content.
904
+ # Defaults to <tt>['meta', 'img', 'link', 'br', 'hr', 'input', 'area', 'param', 'col', 'base']</tt>.
905
+ #
906
+ # [<tt>:preserve</tt>] A list of tag names that should automatically have their newlines preserved
907
+ # using the Haml::Helpers#preserve helper.
908
+ # This means that any content given on the same line as the tag will be preserved.
909
+ # For example:
910
+ #
911
+ # %textarea= "Foo\nBar"
912
+ #
913
+ # compiles to:
914
+ #
915
+ # <textarea>Foo&&#x000A;Bar</textarea>
916
+ #
917
+ # Defaults to <tt>['textarea', 'pre']</tt>.
918
+ #
919
+ # See also Whitespace Preservation, above.
920
+ #
921
+ module Haml
922
+ # Returns a hash representing the version of Haml.
923
+ # The :major, :minor, and :teeny keys have their respective numbers.
924
+ # The :string key contains a human-readable string representation of the version.
925
+ # If Haml is checked out from Git,
926
+ # the :rev key will have the revision hash.
927
+ def self.version
928
+ return @@version if defined?(@@version)
929
+
930
+ numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
931
+ @@version = {
932
+ :major => numbers[0],
933
+ :minor => numbers[1],
934
+ :teeny => numbers[2]
935
+ }
936
+ @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
937
+
938
+ if File.exists?(scope('REVISION'))
939
+ rev = File.read(scope('REVISION')).strip
940
+ rev = nil if rev !~ /a-f0-9+/
941
+ end
942
+
943
+ if rev.nil? && File.exists?(scope('.git/HEAD'))
944
+ rev = File.read(scope('.git/HEAD')).strip
945
+ if rev =~ /^ref: (.*)$/
946
+ rev = File.read(scope(".git/#{$1}")).strip
947
+ end
948
+ end
949
+
950
+ if rev
951
+ @@version[:rev] = rev
952
+ @@version[:string] << "." << rev[0...7]
953
+ end
954
+
955
+ @@version
956
+ end
957
+
958
+ # Returns the path of file relative to the Haml root.
959
+ def self.scope(file) # :nodoc:
960
+ File.join(File.dirname(__FILE__), '..', file)
961
+ end
962
+
963
+ # A string representing the version of Haml.
964
+ # A more fine-grained representation is generated by Haml.version.
965
+ VERSION = version[:string] unless defined?(Haml::VERSION)
966
+
967
+ # This method is called by init.rb,
968
+ # which is run by Rails on startup.
969
+ # We use it rather than putting stuff straight into init.rb
970
+ # so we can change the initialization behavior
971
+ # without modifying the file itself.
972
+ def self.init_rails(binding)
973
+ %w[haml/template sass sass/plugin].each(&method(:require))
974
+ end
975
+ end
976
+
977
+ require 'haml/engine'