spree 0.8.0 → 0.8.1

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

Potentially problematic release.


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

Files changed (181) hide show
  1. data/CHANGELOG +4 -0
  2. data/config/environment.rb +3 -3
  3. data/lib/spree.rb +1 -1
  4. data/public/stylesheets/compiled/screen.css +59 -267
  5. metadata +4 -207
  6. data/vendor/gems/haml-2.1.0/FAQ +0 -138
  7. data/vendor/gems/haml-2.1.0/MIT-LICENSE +0 -20
  8. data/vendor/gems/haml-2.1.0/README.rdoc +0 -332
  9. data/vendor/gems/haml-2.1.0/REVISION +0 -1
  10. data/vendor/gems/haml-2.1.0/Rakefile +0 -185
  11. data/vendor/gems/haml-2.1.0/VERSION +0 -1
  12. data/vendor/gems/haml-2.1.0/bin/css2sass +0 -7
  13. data/vendor/gems/haml-2.1.0/bin/haml +0 -9
  14. data/vendor/gems/haml-2.1.0/bin/html2haml +0 -7
  15. data/vendor/gems/haml-2.1.0/bin/sass +0 -8
  16. data/vendor/gems/haml-2.1.0/extra/haml-mode.el +0 -434
  17. data/vendor/gems/haml-2.1.0/extra/sass-mode.el +0 -98
  18. data/vendor/gems/haml-2.1.0/init.rb +0 -8
  19. data/vendor/gems/haml-2.1.0/lib/haml.rb +0 -1042
  20. data/vendor/gems/haml-2.1.0/lib/haml/buffer.rb +0 -255
  21. data/vendor/gems/haml-2.1.0/lib/haml/engine.rb +0 -268
  22. data/vendor/gems/haml-2.1.0/lib/haml/error.rb +0 -22
  23. data/vendor/gems/haml-2.1.0/lib/haml/exec.rb +0 -395
  24. data/vendor/gems/haml-2.1.0/lib/haml/filters.rb +0 -276
  25. data/vendor/gems/haml-2.1.0/lib/haml/helpers.rb +0 -468
  26. data/vendor/gems/haml-2.1.0/lib/haml/helpers/action_view_extensions.rb +0 -45
  27. data/vendor/gems/haml-2.1.0/lib/haml/helpers/action_view_mods.rb +0 -181
  28. data/vendor/gems/haml-2.1.0/lib/haml/html.rb +0 -218
  29. data/vendor/gems/haml-2.1.0/lib/haml/precompiler.rb +0 -889
  30. data/vendor/gems/haml-2.1.0/lib/haml/shared.rb +0 -45
  31. data/vendor/gems/haml-2.1.0/lib/haml/template.rb +0 -51
  32. data/vendor/gems/haml-2.1.0/lib/haml/template/patch.rb +0 -58
  33. data/vendor/gems/haml-2.1.0/lib/haml/template/plugin.rb +0 -72
  34. data/vendor/gems/haml-2.1.0/lib/haml/util.rb +0 -77
  35. data/vendor/gems/haml-2.1.0/lib/haml/version.rb +0 -47
  36. data/vendor/gems/haml-2.1.0/lib/sass.rb +0 -1062
  37. data/vendor/gems/haml-2.1.0/lib/sass/css.rb +0 -388
  38. data/vendor/gems/haml-2.1.0/lib/sass/engine.rb +0 -499
  39. data/vendor/gems/haml-2.1.0/lib/sass/environment.rb +0 -33
  40. data/vendor/gems/haml-2.1.0/lib/sass/error.rb +0 -35
  41. data/vendor/gems/haml-2.1.0/lib/sass/plugin.rb +0 -203
  42. data/vendor/gems/haml-2.1.0/lib/sass/plugin/merb.rb +0 -56
  43. data/vendor/gems/haml-2.1.0/lib/sass/plugin/rails.rb +0 -24
  44. data/vendor/gems/haml-2.1.0/lib/sass/repl.rb +0 -51
  45. data/vendor/gems/haml-2.1.0/lib/sass/script.rb +0 -38
  46. data/vendor/gems/haml-2.1.0/lib/sass/script/bool.rb +0 -13
  47. data/vendor/gems/haml-2.1.0/lib/sass/script/color.rb +0 -97
  48. data/vendor/gems/haml-2.1.0/lib/sass/script/funcall.rb +0 -28
  49. data/vendor/gems/haml-2.1.0/lib/sass/script/functions.rb +0 -122
  50. data/vendor/gems/haml-2.1.0/lib/sass/script/lexer.rb +0 -152
  51. data/vendor/gems/haml-2.1.0/lib/sass/script/literal.rb +0 -60
  52. data/vendor/gems/haml-2.1.0/lib/sass/script/number.rb +0 -231
  53. data/vendor/gems/haml-2.1.0/lib/sass/script/operation.rb +0 -30
  54. data/vendor/gems/haml-2.1.0/lib/sass/script/parser.rb +0 -142
  55. data/vendor/gems/haml-2.1.0/lib/sass/script/string.rb +0 -42
  56. data/vendor/gems/haml-2.1.0/lib/sass/script/unary_operation.rb +0 -21
  57. data/vendor/gems/haml-2.1.0/lib/sass/script/variable.rb +0 -20
  58. data/vendor/gems/haml-2.1.0/lib/sass/tree/attr_node.rb +0 -64
  59. data/vendor/gems/haml-2.1.0/lib/sass/tree/comment_node.rb +0 -34
  60. data/vendor/gems/haml-2.1.0/lib/sass/tree/debug_node.rb +0 -22
  61. data/vendor/gems/haml-2.1.0/lib/sass/tree/directive_node.rb +0 -50
  62. data/vendor/gems/haml-2.1.0/lib/sass/tree/file_node.rb +0 -27
  63. data/vendor/gems/haml-2.1.0/lib/sass/tree/for_node.rb +0 -29
  64. data/vendor/gems/haml-2.1.0/lib/sass/tree/if_node.rb +0 -27
  65. data/vendor/gems/haml-2.1.0/lib/sass/tree/mixin_def_node.rb +0 -18
  66. data/vendor/gems/haml-2.1.0/lib/sass/tree/mixin_node.rb +0 -34
  67. data/vendor/gems/haml-2.1.0/lib/sass/tree/node.rb +0 -99
  68. data/vendor/gems/haml-2.1.0/lib/sass/tree/rule_node.rb +0 -120
  69. data/vendor/gems/haml-2.1.0/lib/sass/tree/variable_node.rb +0 -24
  70. data/vendor/gems/haml-2.1.0/lib/sass/tree/while_node.rb +0 -20
  71. data/vendor/gems/haml-2.1.0/rails/init.rb +0 -1
  72. data/vendor/gems/haml-2.1.0/test/benchmark.rb +0 -99
  73. data/vendor/gems/haml-2.1.0/test/haml/engine_test.rb +0 -734
  74. data/vendor/gems/haml-2.1.0/test/haml/helper_test.rb +0 -224
  75. data/vendor/gems/haml-2.1.0/test/haml/html2haml_test.rb +0 -92
  76. data/vendor/gems/haml-2.1.0/test/haml/markaby/standard.mab +0 -52
  77. data/vendor/gems/haml-2.1.0/test/haml/mocks/article.rb +0 -6
  78. data/vendor/gems/haml-2.1.0/test/haml/results/content_for_layout.xhtml +0 -15
  79. data/vendor/gems/haml-2.1.0/test/haml/results/eval_suppressed.xhtml +0 -9
  80. data/vendor/gems/haml-2.1.0/test/haml/results/filters.xhtml +0 -62
  81. data/vendor/gems/haml-2.1.0/test/haml/results/helpers.xhtml +0 -93
  82. data/vendor/gems/haml-2.1.0/test/haml/results/helpful.xhtml +0 -10
  83. data/vendor/gems/haml-2.1.0/test/haml/results/just_stuff.xhtml +0 -68
  84. data/vendor/gems/haml-2.1.0/test/haml/results/list.xhtml +0 -12
  85. data/vendor/gems/haml-2.1.0/test/haml/results/nuke_inner_whitespace.xhtml +0 -40
  86. data/vendor/gems/haml-2.1.0/test/haml/results/nuke_outer_whitespace.xhtml +0 -148
  87. data/vendor/gems/haml-2.1.0/test/haml/results/original_engine.xhtml +0 -20
  88. data/vendor/gems/haml-2.1.0/test/haml/results/partial_layout.xhtml +0 -5
  89. data/vendor/gems/haml-2.1.0/test/haml/results/partials.xhtml +0 -21
  90. data/vendor/gems/haml-2.1.0/test/haml/results/render_layout.xhtml +0 -3
  91. data/vendor/gems/haml-2.1.0/test/haml/results/silent_script.xhtml +0 -74
  92. data/vendor/gems/haml-2.1.0/test/haml/results/standard.xhtml +0 -42
  93. data/vendor/gems/haml-2.1.0/test/haml/results/tag_parsing.xhtml +0 -23
  94. data/vendor/gems/haml-2.1.0/test/haml/results/very_basic.xhtml +0 -5
  95. data/vendor/gems/haml-2.1.0/test/haml/results/whitespace_handling.xhtml +0 -89
  96. data/vendor/gems/haml-2.1.0/test/haml/rhtml/_av_partial_1.rhtml +0 -12
  97. data/vendor/gems/haml-2.1.0/test/haml/rhtml/_av_partial_2.rhtml +0 -8
  98. data/vendor/gems/haml-2.1.0/test/haml/rhtml/action_view.rhtml +0 -62
  99. data/vendor/gems/haml-2.1.0/test/haml/rhtml/standard.rhtml +0 -54
  100. data/vendor/gems/haml-2.1.0/test/haml/template_test.rb +0 -204
  101. data/vendor/gems/haml-2.1.0/test/haml/templates/_av_partial_1.haml +0 -9
  102. data/vendor/gems/haml-2.1.0/test/haml/templates/_av_partial_1_ugly.haml +0 -9
  103. data/vendor/gems/haml-2.1.0/test/haml/templates/_av_partial_2.haml +0 -5
  104. data/vendor/gems/haml-2.1.0/test/haml/templates/_av_partial_2_ugly.haml +0 -5
  105. data/vendor/gems/haml-2.1.0/test/haml/templates/_layout.erb +0 -3
  106. data/vendor/gems/haml-2.1.0/test/haml/templates/_layout_for_partial.haml +0 -3
  107. data/vendor/gems/haml-2.1.0/test/haml/templates/_partial.haml +0 -8
  108. data/vendor/gems/haml-2.1.0/test/haml/templates/_text_area.haml +0 -3
  109. data/vendor/gems/haml-2.1.0/test/haml/templates/action_view.haml +0 -47
  110. data/vendor/gems/haml-2.1.0/test/haml/templates/action_view_ugly.haml +0 -47
  111. data/vendor/gems/haml-2.1.0/test/haml/templates/breakage.haml +0 -8
  112. data/vendor/gems/haml-2.1.0/test/haml/templates/content_for_layout.haml +0 -10
  113. data/vendor/gems/haml-2.1.0/test/haml/templates/eval_suppressed.haml +0 -11
  114. data/vendor/gems/haml-2.1.0/test/haml/templates/filters.haml +0 -66
  115. data/vendor/gems/haml-2.1.0/test/haml/templates/helpers.haml +0 -95
  116. data/vendor/gems/haml-2.1.0/test/haml/templates/helpful.haml +0 -11
  117. data/vendor/gems/haml-2.1.0/test/haml/templates/just_stuff.haml +0 -83
  118. data/vendor/gems/haml-2.1.0/test/haml/templates/list.haml +0 -12
  119. data/vendor/gems/haml-2.1.0/test/haml/templates/nuke_inner_whitespace.haml +0 -32
  120. data/vendor/gems/haml-2.1.0/test/haml/templates/nuke_outer_whitespace.haml +0 -144
  121. data/vendor/gems/haml-2.1.0/test/haml/templates/original_engine.haml +0 -17
  122. data/vendor/gems/haml-2.1.0/test/haml/templates/partial_layout.haml +0 -3
  123. data/vendor/gems/haml-2.1.0/test/haml/templates/partialize.haml +0 -1
  124. data/vendor/gems/haml-2.1.0/test/haml/templates/partials.haml +0 -12
  125. data/vendor/gems/haml-2.1.0/test/haml/templates/render_layout.haml +0 -2
  126. data/vendor/gems/haml-2.1.0/test/haml/templates/silent_script.haml +0 -40
  127. data/vendor/gems/haml-2.1.0/test/haml/templates/standard.haml +0 -42
  128. data/vendor/gems/haml-2.1.0/test/haml/templates/standard_ugly.haml +0 -42
  129. data/vendor/gems/haml-2.1.0/test/haml/templates/tag_parsing.haml +0 -21
  130. data/vendor/gems/haml-2.1.0/test/haml/templates/very_basic.haml +0 -4
  131. data/vendor/gems/haml-2.1.0/test/haml/templates/whitespace_handling.haml +0 -87
  132. data/vendor/gems/haml-2.1.0/test/linked_rails.rb +0 -12
  133. data/vendor/gems/haml-2.1.0/test/sass/css2sass_test.rb +0 -193
  134. data/vendor/gems/haml-2.1.0/test/sass/engine_test.rb +0 -769
  135. data/vendor/gems/haml-2.1.0/test/sass/functions_test.rb +0 -96
  136. data/vendor/gems/haml-2.1.0/test/sass/more_results/more1.css +0 -9
  137. data/vendor/gems/haml-2.1.0/test/sass/more_results/more1_with_line_comments.css +0 -26
  138. data/vendor/gems/haml-2.1.0/test/sass/more_results/more_import.css +0 -29
  139. data/vendor/gems/haml-2.1.0/test/sass/more_templates/_more_partial.sass +0 -2
  140. data/vendor/gems/haml-2.1.0/test/sass/more_templates/more1.sass +0 -23
  141. data/vendor/gems/haml-2.1.0/test/sass/more_templates/more_import.sass +0 -11
  142. data/vendor/gems/haml-2.1.0/test/sass/plugin_test.rb +0 -208
  143. data/vendor/gems/haml-2.1.0/test/sass/results/alt.css +0 -4
  144. data/vendor/gems/haml-2.1.0/test/sass/results/basic.css +0 -9
  145. data/vendor/gems/haml-2.1.0/test/sass/results/compact.css +0 -5
  146. data/vendor/gems/haml-2.1.0/test/sass/results/complex.css +0 -87
  147. data/vendor/gems/haml-2.1.0/test/sass/results/compressed.css +0 -1
  148. data/vendor/gems/haml-2.1.0/test/sass/results/expanded.css +0 -19
  149. data/vendor/gems/haml-2.1.0/test/sass/results/import.css +0 -29
  150. data/vendor/gems/haml-2.1.0/test/sass/results/line_numbers.css +0 -49
  151. data/vendor/gems/haml-2.1.0/test/sass/results/mixins.css +0 -95
  152. data/vendor/gems/haml-2.1.0/test/sass/results/multiline.css +0 -24
  153. data/vendor/gems/haml-2.1.0/test/sass/results/nested.css +0 -22
  154. data/vendor/gems/haml-2.1.0/test/sass/results/parent_ref.css +0 -13
  155. data/vendor/gems/haml-2.1.0/test/sass/results/script.css +0 -16
  156. data/vendor/gems/haml-2.1.0/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  157. data/vendor/gems/haml-2.1.0/test/sass/results/subdir/subdir.css +0 -3
  158. data/vendor/gems/haml-2.1.0/test/sass/results/units.css +0 -11
  159. data/vendor/gems/haml-2.1.0/test/sass/script_test.rb +0 -153
  160. data/vendor/gems/haml-2.1.0/test/sass/templates/_partial.sass +0 -2
  161. data/vendor/gems/haml-2.1.0/test/sass/templates/alt.sass +0 -16
  162. data/vendor/gems/haml-2.1.0/test/sass/templates/basic.sass +0 -23
  163. data/vendor/gems/haml-2.1.0/test/sass/templates/bork.sass +0 -2
  164. data/vendor/gems/haml-2.1.0/test/sass/templates/bork2.sass +0 -2
  165. data/vendor/gems/haml-2.1.0/test/sass/templates/compact.sass +0 -17
  166. data/vendor/gems/haml-2.1.0/test/sass/templates/complex.sass +0 -309
  167. data/vendor/gems/haml-2.1.0/test/sass/templates/compressed.sass +0 -15
  168. data/vendor/gems/haml-2.1.0/test/sass/templates/expanded.sass +0 -17
  169. data/vendor/gems/haml-2.1.0/test/sass/templates/import.sass +0 -11
  170. data/vendor/gems/haml-2.1.0/test/sass/templates/importee.sass +0 -19
  171. data/vendor/gems/haml-2.1.0/test/sass/templates/line_numbers.sass +0 -13
  172. data/vendor/gems/haml-2.1.0/test/sass/templates/mixins.sass +0 -76
  173. data/vendor/gems/haml-2.1.0/test/sass/templates/multiline.sass +0 -20
  174. data/vendor/gems/haml-2.1.0/test/sass/templates/nested.sass +0 -25
  175. data/vendor/gems/haml-2.1.0/test/sass/templates/parent_ref.sass +0 -25
  176. data/vendor/gems/haml-2.1.0/test/sass/templates/script.sass +0 -101
  177. data/vendor/gems/haml-2.1.0/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  178. data/vendor/gems/haml-2.1.0/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  179. data/vendor/gems/haml-2.1.0/test/sass/templates/subdir/subdir.sass +0 -6
  180. data/vendor/gems/haml-2.1.0/test/sass/templates/units.sass +0 -11
  181. data/vendor/gems/haml-2.1.0/test/test_helper.rb +0 -21
@@ -1,468 +0,0 @@
1
- require 'haml/helpers/action_view_mods'
2
- require 'haml/helpers/action_view_extensions'
3
-
4
- module Haml
5
- # This module contains various helpful methods to make it easier to do
6
- # various tasks. Haml::Helpers is automatically included in the context
7
- # that a Haml template is parsed in, so all these methods are at your
8
- # disposal from within the template.
9
- module Helpers
10
- self.extend self
11
-
12
- @@action_view_defined = defined?(ActionView)
13
- @@force_no_action_view = false
14
-
15
- # Returns whether or not ActionView is installed on the system.
16
- def self.action_view?
17
- @@action_view_defined
18
- end
19
-
20
- # Note: this does *not* need to be called
21
- # when using Haml helpers normally
22
- # in Rails.
23
- #
24
- # Initializes the current object
25
- # as though it were in the same context
26
- # as a normal ActionView rendering
27
- # using Haml.
28
- # This is useful if you want to use the helpers in a context
29
- # other than the normal setup with ActionView.
30
- # For example:
31
- #
32
- # context = Object.new
33
- # class << context
34
- # include Haml::Helpers
35
- # end
36
- # context.init_haml_helpers
37
- # context.haml_tag :p, "Stuff"
38
- #
39
- def init_haml_helpers
40
- @haml_buffer = Haml::Buffer.new(@haml_buffer, Haml::Engine.new('').send(:options_for_buffer))
41
- nil
42
- end
43
-
44
- # call-seq:
45
- # non_haml { ... }
46
- #
47
- # Runs a block of code in a non-Haml context
48
- # (i.e. #is_haml? will return false).
49
- #
50
- # This is mainly useful for rendering sub-templates such as partials in a non-Haml language,
51
- # particularly where helpers may behave differently when run from Haml.
52
- #
53
- # Note that this is automatically applied to Rails partials.
54
- def non_haml
55
- was_active = @haml_buffer.active?
56
- @haml_buffer.active = false
57
- yield
58
- ensure
59
- @haml_buffer.active = was_active
60
- end
61
-
62
- # call-seq:
63
- # find_and_preserve(input, tags = haml_buffer.options[:preserve])
64
- # find_and_preserve {...}
65
- #
66
- # Uses preserve to convert any newlines inside whitespace-sensitive tags
67
- # into the HTML entities for endlines.
68
- # @tags@ is an array of tags to preserve.
69
- # It defaults to the value of the <tt>:preserve</tt> option.
70
- def find_and_preserve(input = '', tags = haml_buffer.options[:preserve], &block)
71
- return find_and_preserve(capture_haml(&block)) if block
72
-
73
- input = input.to_s
74
- input.gsub(/<(#{tags.map(&Regexp.method(:escape)).join('|')})([^>]*)>(.*?)(<\/\1>)/im) do
75
- "<#{$1}#{$2}>#{preserve($3)}</#{$1}>"
76
- end
77
- end
78
-
79
- # call-seq:
80
- # preserve(input)
81
- # preserve {...}
82
- #
83
- # Takes any string, finds all the endlines and converts them to
84
- # HTML entities for endlines so they'll render correctly in
85
- # whitespace-sensitive tags without screwing up the indentation.
86
- def preserve(input = '', &block)
87
- return preserve(capture_haml(&block)) if block
88
-
89
- input.chomp("\n").gsub(/\n/, '&#x000A;').gsub(/\r/, '')
90
- end
91
-
92
- alias_method :flatten, :preserve
93
-
94
- # Takes an Enumerable object and a block
95
- # and iterates over the object,
96
- # yielding each element to a Haml block
97
- # and putting the result into <tt><li></tt> elements.
98
- # This creates a list of the results of the block.
99
- # For example:
100
- #
101
- # = list_of([['hello'], ['yall']]) do |i|
102
- # = i[0]
103
- #
104
- # Produces:
105
- #
106
- # <li>hello</li>
107
- # <li>yall</li>
108
- #
109
- # And
110
- #
111
- # = list_of({:title => 'All the stuff', :description => 'A book about all the stuff.'}) do |key, val|
112
- # %h3= key.humanize
113
- # %p= val
114
- #
115
- # Produces:
116
- #
117
- # <li>
118
- # <h3>Title</h3>
119
- # <p>All the stuff</p>
120
- # </li>
121
- # <li>
122
- # <h3>Description</h3>
123
- # <p>A book about all the stuff.</p>
124
- # </li>
125
- #
126
- def list_of(array, &block) # :yields: item
127
- to_return = array.collect do |i|
128
- result = capture_haml(i, &block)
129
-
130
- if result.count("\n") > 1
131
- result.gsub!("\n", "\n ")
132
- result = "\n #{result.strip}\n"
133
- else
134
- result.strip!
135
- end
136
-
137
- "<li>#{result}</li>"
138
- end
139
- to_return.join("\n")
140
- end
141
-
142
- # Returns a hash containing default assignments for the xmlns and xml:lang
143
- # attributes of the <tt>html</tt> HTML element.
144
- # It also takes an optional argument for the value of xml:lang and lang,
145
- # which defaults to 'en-US'.
146
- # For example,
147
- #
148
- # %html{html_attrs}
149
- #
150
- # becomes
151
- #
152
- # <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US' lang='en-US'>
153
- #
154
- def html_attrs(lang = 'en-US')
155
- {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
156
- end
157
-
158
- # Increments the number of tabs the buffer automatically adds
159
- # to the lines of the template.
160
- # For example:
161
- #
162
- # %h1 foo
163
- # - tab_up
164
- # %p bar
165
- # - tab_down
166
- # %strong baz
167
- #
168
- # Produces:
169
- #
170
- # <h1>foo</h1>
171
- # <p>bar</p>
172
- # <strong>baz</strong>
173
- #
174
- def tab_up(i = 1)
175
- haml_buffer.tabulation += i
176
- end
177
-
178
- # Decrements the number of tabs the buffer automatically adds
179
- # to the lines of the template.
180
- #
181
- # See also tab_up.
182
- def tab_down(i = 1)
183
- haml_buffer.tabulation -= i
184
- end
185
-
186
- # Surrounds the given block of Haml code with the given characters,
187
- # with no whitespace in between.
188
- # For example:
189
- #
190
- # = surround '(', ')' do
191
- # %a{:href => "food"} chicken
192
- #
193
- # Produces:
194
- #
195
- # (<a href='food'>chicken</a>)
196
- #
197
- # and
198
- #
199
- # = surround '*' do
200
- # %strong angry
201
- #
202
- # Produces:
203
- #
204
- # *<strong>angry</strong>*
205
- #
206
- def surround(front, back = nil, &block)
207
- back ||= front
208
- output = capture_haml(&block)
209
-
210
- "#{front}#{output.chomp}#{back}\n"
211
- end
212
-
213
- # Prepends the given character to the beginning of the Haml block,
214
- # with no whitespace between.
215
- # For example:
216
- #
217
- # = precede '*' do
218
- # %span.small Not really
219
- #
220
- # Produces:
221
- #
222
- # *<span class='small'>Not really</span>
223
- #
224
- def precede(char, &block)
225
- "#{char}#{capture_haml(&block).chomp}\n"
226
- end
227
-
228
- # Appends the given character to the end of the Haml block,
229
- # with no whitespace between.
230
- # For example:
231
- #
232
- # click
233
- # = succeed '.' do
234
- # %a{:href=>"thing"} here
235
- #
236
- # Produces:
237
- #
238
- # click
239
- # <a href='thing'>here</a>.
240
- #
241
- def succeed(char, &block)
242
- "#{capture_haml(&block).chomp}#{char}\n"
243
- end
244
-
245
- # Captures the result of the given block of Haml code,
246
- # gets rid of the excess indentation,
247
- # and returns it as a string.
248
- # For example, after the following,
249
- #
250
- # .foo
251
- # - foo = capture_haml(13) do |a|
252
- # %p= a
253
- #
254
- # the local variable <tt>foo</tt> would be assigned to "<p>13</p>\n".
255
- #
256
- def capture_haml(*args, &block)
257
- buffer = eval('_hamlout', block.binding) rescue haml_buffer
258
- with_haml_buffer(buffer) do
259
- position = haml_buffer.buffer.length
260
-
261
- block.call(*args)
262
-
263
- captured = haml_buffer.buffer.slice!(position..-1).split(/^/)
264
-
265
- min_tabs = nil
266
- captured.each do |line|
267
- tabs = line.index(/[^ ]/) || line.length
268
- min_tabs ||= tabs
269
- min_tabs = min_tabs > tabs ? tabs : min_tabs
270
- end
271
-
272
- captured.map do |line|
273
- line[min_tabs..-1]
274
- end.join
275
- end
276
- end
277
-
278
- def puts(*args) # :nodoc:
279
- warn <<END
280
- DEPRECATION WARNING:
281
- The Haml #puts helper is deprecated and will be removed in version 2.4.
282
- Use the #haml_concat helper instead.
283
- END
284
- haml_concat *args
285
- end
286
-
287
- # Outputs text directly to the Haml buffer, with the proper tabulation
288
- def haml_concat(text = "")
289
- haml_buffer.buffer << haml_indent << text.to_s << "\n"
290
- nil
291
- end
292
-
293
- # Returns the string that should be used to indent the current line
294
- def haml_indent
295
- ' ' * haml_buffer.tabulation
296
- end
297
-
298
- #
299
- # call-seq:
300
- # haml_tag(name, *flags, attributes = {}) {...}
301
- # haml_tag(name, text, *flags, attributes = {}) {...}
302
- #
303
- # Creates an HTML tag with the given name and optionally text and attributes.
304
- # Can take a block that will be executed
305
- # between when the opening and closing tags are output.
306
- # If the block is a Haml block or outputs text using haml_concat,
307
- # the text will be properly indented.
308
- #
309
- # <tt>flags</tt> is a list of symbol flags
310
- # like those that can be put at the end of a Haml tag
311
- # (<tt>:/</tt>, <tt>:<</tt>, and <tt>:></tt>).
312
- # Currently, only <tt>:/</tt> and <tt>:<</tt> are supported.
313
- #
314
- # For example,
315
- #
316
- # haml_tag :table do
317
- # haml_tag :tr do
318
- # haml_tag :td, {:class => 'cell'} do
319
- # haml_tag :strong, "strong!"
320
- # haml_concat "data"
321
- # end
322
- # haml_tag :td do
323
- # haml_concat "more_data"
324
- # end
325
- # end
326
- # end
327
- #
328
- # outputs
329
- #
330
- # <table>
331
- # <tr>
332
- # <td class='cell'>
333
- # <strong>
334
- # strong!
335
- # </strong>
336
- # data
337
- # </td>
338
- # <td>
339
- # more_data
340
- # </td>
341
- # </tr>
342
- # </table>
343
- #
344
- def haml_tag(name, *rest, &block)
345
- name = name.to_s
346
- text = rest.shift.to_s unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t}
347
- flags = []
348
- flags << rest.shift while rest.first.is_a? Symbol
349
- attributes = Haml::Precompiler.build_attributes(haml_buffer.html?,
350
- haml_buffer.options[:attr_wrapper],
351
- rest.shift || {})
352
-
353
- if text.nil? && block.nil? && (haml_buffer.options[:autoclose].include?(name) || flags.include?(:/))
354
- haml_concat "<#{name}#{attributes} />"
355
- return nil
356
- end
357
-
358
- if flags.include?(:/)
359
- raise Error.new("Self-closing tags can't have content.") if text
360
- raise Error.new("Illegal nesting: nesting within a self-closing tag is illegal.") if block
361
- end
362
-
363
- tag = "<#{name}#{attributes}>"
364
- if block.nil?
365
- tag << text.to_s << "</#{name}>"
366
- haml_concat tag
367
- return
368
- end
369
-
370
- if text
371
- raise Error.new("Illegal nesting: content can't be both given to haml_tag :#{name} and nested within it.")
372
- end
373
-
374
- if flags.include?(:<)
375
- tag << capture_haml(&block).strip << "</#{name}>"
376
- haml_concat tag
377
- return
378
- end
379
-
380
- haml_concat tag
381
- tab_up
382
- block.call
383
- tab_down
384
- haml_concat "</#{name}>"
385
- <<MESSAGE
386
- <h1><code>haml_tag</code> outputs directly to the Haml template.
387
- Disregard its return value and use the <code>-</code> operator.</h1>
388
- MESSAGE
389
- end
390
-
391
- # Characters that need to be escaped to HTML entities from user input
392
- HTML_ESCAPE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
393
-
394
- # Returns a copy of <tt>text</tt> with ampersands, angle brackets and quotes
395
- # escaped into HTML entities.
396
- def html_escape(text)
397
- text.to_s.gsub(/[\"><&]/) { |s| HTML_ESCAPE[s] }
398
- end
399
-
400
- # Escapes HTML entities in <tt>text</tt>, but without escaping an ampersand
401
- # that is already part of an escaped entity.
402
- def escape_once(text)
403
- text.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |s| HTML_ESCAPE[s] }
404
- end
405
-
406
- # Returns whether or not the current template is a Haml template.
407
- #
408
- # This function, unlike other Haml::Helpers functions,
409
- # also works in other ActionView templates,
410
- # where it will always return false.
411
- def is_haml?
412
- !@haml_buffer.nil? && @haml_buffer.active?
413
- end
414
-
415
- # Returns whether or not +block+ is defined directly in a Haml template.
416
- def block_is_haml?(block)
417
- eval('_hamlout', block.binding)
418
- true
419
- rescue
420
- false
421
- end
422
-
423
- private
424
-
425
- # call-seq:
426
- # with_haml_buffer(buffer) {...}
427
- #
428
- # Runs the block with the given buffer as the currently active buffer.
429
- def with_haml_buffer(buffer)
430
- @haml_buffer, old_buffer = buffer, @haml_buffer
431
- old_buffer.active, was_active = false, old_buffer.active? if old_buffer
432
- @haml_buffer.active = true
433
- yield
434
- ensure
435
- @haml_buffer.active = false
436
- old_buffer.active = was_active if old_buffer
437
- @haml_buffer = old_buffer
438
- end
439
-
440
- # Gets a reference to the current Haml::Buffer object.
441
- def haml_buffer
442
- @haml_buffer
443
- end
444
-
445
- # Gives a proc the same local "_hamlout" and "_erbout" variables
446
- # that the current template has.
447
- def haml_bind_proc(&proc)
448
- _hamlout = haml_buffer
449
- _erbout = _hamlout.buffer
450
- proc { |*args| proc.call(*args) }
451
- end
452
-
453
- include ActionViewExtensions if self.const_defined? "ActionViewExtensions"
454
- end
455
- end
456
-
457
- class Object
458
- # Haml overrides various ActionView helpers,
459
- # which call an #is_haml? method
460
- # to determine whether or not the current context object
461
- # is a proper Haml context.
462
- # Because ActionView helpers may be included in non-ActionView::Base classes,
463
- # it's a good idea to define is_haml? for all objects.
464
- def is_haml?
465
- false
466
- end
467
- end
468
-