merbjedi-haml 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/FAQ +138 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +332 -0
  4. data/REVISION +1 -0
  5. data/Rakefile +184 -0
  6. data/VERSION +1 -0
  7. data/bin/css2sass +7 -0
  8. data/bin/haml +9 -0
  9. data/bin/html2haml +7 -0
  10. data/bin/sass +8 -0
  11. data/extra/haml-mode.el +434 -0
  12. data/extra/sass-mode.el +98 -0
  13. data/init.rb +8 -0
  14. data/lib/haml.rb +1025 -0
  15. data/lib/haml/buffer.rb +255 -0
  16. data/lib/haml/engine.rb +268 -0
  17. data/lib/haml/error.rb +22 -0
  18. data/lib/haml/exec.rb +395 -0
  19. data/lib/haml/filters.rb +276 -0
  20. data/lib/haml/helpers.rb +465 -0
  21. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  22. data/lib/haml/helpers/action_view_mods.rb +181 -0
  23. data/lib/haml/html.rb +218 -0
  24. data/lib/haml/precompiler.rb +896 -0
  25. data/lib/haml/shared.rb +45 -0
  26. data/lib/haml/template.rb +51 -0
  27. data/lib/haml/template/patch.rb +58 -0
  28. data/lib/haml/template/plugin.rb +72 -0
  29. data/lib/haml/util.rb +77 -0
  30. data/lib/haml/version.rb +47 -0
  31. data/lib/sass.rb +1062 -0
  32. data/lib/sass/css.rb +388 -0
  33. data/lib/sass/engine.rb +501 -0
  34. data/lib/sass/environment.rb +33 -0
  35. data/lib/sass/error.rb +35 -0
  36. data/lib/sass/plugin.rb +203 -0
  37. data/lib/sass/plugin/merb.rb +56 -0
  38. data/lib/sass/plugin/rails.rb +24 -0
  39. data/lib/sass/repl.rb +44 -0
  40. data/lib/sass/script.rb +38 -0
  41. data/lib/sass/script/bool.rb +13 -0
  42. data/lib/sass/script/color.rb +97 -0
  43. data/lib/sass/script/funcall.rb +28 -0
  44. data/lib/sass/script/functions.rb +122 -0
  45. data/lib/sass/script/lexer.rb +144 -0
  46. data/lib/sass/script/literal.rb +60 -0
  47. data/lib/sass/script/number.rb +231 -0
  48. data/lib/sass/script/operation.rb +30 -0
  49. data/lib/sass/script/parser.rb +142 -0
  50. data/lib/sass/script/string.rb +42 -0
  51. data/lib/sass/script/unary_operation.rb +21 -0
  52. data/lib/sass/script/variable.rb +20 -0
  53. data/lib/sass/tree/attr_node.rb +64 -0
  54. data/lib/sass/tree/comment_node.rb +30 -0
  55. data/lib/sass/tree/debug_node.rb +22 -0
  56. data/lib/sass/tree/directive_node.rb +50 -0
  57. data/lib/sass/tree/file_node.rb +27 -0
  58. data/lib/sass/tree/for_node.rb +29 -0
  59. data/lib/sass/tree/if_node.rb +27 -0
  60. data/lib/sass/tree/mixin_def_node.rb +18 -0
  61. data/lib/sass/tree/mixin_node.rb +34 -0
  62. data/lib/sass/tree/node.rb +97 -0
  63. data/lib/sass/tree/rule_node.rb +120 -0
  64. data/lib/sass/tree/variable_node.rb +24 -0
  65. data/lib/sass/tree/while_node.rb +20 -0
  66. data/rails/init.rb +1 -0
  67. data/test/benchmark.rb +99 -0
  68. data/test/haml/engine_test.rb +852 -0
  69. data/test/haml/helper_test.rb +224 -0
  70. data/test/haml/html2haml_test.rb +92 -0
  71. data/test/haml/markaby/standard.mab +52 -0
  72. data/test/haml/mocks/article.rb +6 -0
  73. data/test/haml/results/content_for_layout.xhtml +15 -0
  74. data/test/haml/results/eval_suppressed.xhtml +9 -0
  75. data/test/haml/results/filters.xhtml +62 -0
  76. data/test/haml/results/helpers.xhtml +93 -0
  77. data/test/haml/results/helpful.xhtml +10 -0
  78. data/test/haml/results/just_stuff.xhtml +68 -0
  79. data/test/haml/results/list.xhtml +12 -0
  80. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  81. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  82. data/test/haml/results/original_engine.xhtml +20 -0
  83. data/test/haml/results/partial_layout.xhtml +5 -0
  84. data/test/haml/results/partials.xhtml +21 -0
  85. data/test/haml/results/render_layout.xhtml +3 -0
  86. data/test/haml/results/silent_script.xhtml +74 -0
  87. data/test/haml/results/standard.xhtml +42 -0
  88. data/test/haml/results/tag_parsing.xhtml +23 -0
  89. data/test/haml/results/very_basic.xhtml +5 -0
  90. data/test/haml/results/whitespace_handling.xhtml +89 -0
  91. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  92. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  93. data/test/haml/rhtml/action_view.rhtml +62 -0
  94. data/test/haml/rhtml/standard.rhtml +54 -0
  95. data/test/haml/template_test.rb +204 -0
  96. data/test/haml/templates/_av_partial_1.haml +9 -0
  97. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  98. data/test/haml/templates/_av_partial_2.haml +5 -0
  99. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  100. data/test/haml/templates/_layout.erb +3 -0
  101. data/test/haml/templates/_layout_for_partial.haml +3 -0
  102. data/test/haml/templates/_partial.haml +8 -0
  103. data/test/haml/templates/_text_area.haml +3 -0
  104. data/test/haml/templates/action_view.haml +47 -0
  105. data/test/haml/templates/action_view_ugly.haml +47 -0
  106. data/test/haml/templates/breakage.haml +8 -0
  107. data/test/haml/templates/content_for_layout.haml +10 -0
  108. data/test/haml/templates/eval_suppressed.haml +11 -0
  109. data/test/haml/templates/filters.haml +66 -0
  110. data/test/haml/templates/helpers.haml +95 -0
  111. data/test/haml/templates/helpful.haml +11 -0
  112. data/test/haml/templates/just_stuff.haml +83 -0
  113. data/test/haml/templates/list.haml +12 -0
  114. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  115. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  116. data/test/haml/templates/original_engine.haml +17 -0
  117. data/test/haml/templates/partial_layout.haml +3 -0
  118. data/test/haml/templates/partialize.haml +1 -0
  119. data/test/haml/templates/partials.haml +12 -0
  120. data/test/haml/templates/render_layout.haml +2 -0
  121. data/test/haml/templates/silent_script.haml +40 -0
  122. data/test/haml/templates/standard.haml +42 -0
  123. data/test/haml/templates/standard_ugly.haml +42 -0
  124. data/test/haml/templates/tag_parsing.haml +21 -0
  125. data/test/haml/templates/very_basic.haml +4 -0
  126. data/test/haml/templates/whitespace_handling.haml +87 -0
  127. data/test/linked_rails.rb +12 -0
  128. data/test/sass/css2sass_test.rb +193 -0
  129. data/test/sass/engine_test.rb +752 -0
  130. data/test/sass/functions_test.rb +96 -0
  131. data/test/sass/more_results/more1.css +9 -0
  132. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  133. data/test/sass/more_results/more_import.css +29 -0
  134. data/test/sass/more_templates/_more_partial.sass +2 -0
  135. data/test/sass/more_templates/more1.sass +23 -0
  136. data/test/sass/more_templates/more_import.sass +11 -0
  137. data/test/sass/plugin_test.rb +208 -0
  138. data/test/sass/results/alt.css +4 -0
  139. data/test/sass/results/basic.css +9 -0
  140. data/test/sass/results/compact.css +5 -0
  141. data/test/sass/results/complex.css +87 -0
  142. data/test/sass/results/compressed.css +1 -0
  143. data/test/sass/results/expanded.css +19 -0
  144. data/test/sass/results/import.css +29 -0
  145. data/test/sass/results/line_numbers.css +49 -0
  146. data/test/sass/results/mixins.css +95 -0
  147. data/test/sass/results/multiline.css +24 -0
  148. data/test/sass/results/nested.css +22 -0
  149. data/test/sass/results/parent_ref.css +13 -0
  150. data/test/sass/results/script.css +16 -0
  151. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  152. data/test/sass/results/subdir/subdir.css +3 -0
  153. data/test/sass/results/units.css +11 -0
  154. data/test/sass/script_test.rb +152 -0
  155. data/test/sass/templates/_partial.sass +2 -0
  156. data/test/sass/templates/alt.sass +16 -0
  157. data/test/sass/templates/basic.sass +23 -0
  158. data/test/sass/templates/bork.sass +2 -0
  159. data/test/sass/templates/bork2.sass +2 -0
  160. data/test/sass/templates/compact.sass +17 -0
  161. data/test/sass/templates/complex.sass +309 -0
  162. data/test/sass/templates/compressed.sass +15 -0
  163. data/test/sass/templates/expanded.sass +17 -0
  164. data/test/sass/templates/import.sass +11 -0
  165. data/test/sass/templates/importee.sass +19 -0
  166. data/test/sass/templates/line_numbers.sass +13 -0
  167. data/test/sass/templates/mixins.sass +76 -0
  168. data/test/sass/templates/multiline.sass +20 -0
  169. data/test/sass/templates/nested.sass +25 -0
  170. data/test/sass/templates/parent_ref.sass +25 -0
  171. data/test/sass/templates/script.sass +101 -0
  172. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  173. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  174. data/test/sass/templates/subdir/subdir.sass +6 -0
  175. data/test/sass/templates/units.sass +11 -0
  176. data/test/test_helper.rb +21 -0
  177. metadata +273 -0
@@ -0,0 +1,33 @@
1
+ module Sass
2
+ class Environment
3
+ attr_reader :parent
4
+
5
+ def initialize(parent = nil)
6
+ @vars = {}
7
+ @mixins = {}
8
+ @parent = parent
9
+ end
10
+
11
+ def self.inherited_hash(name)
12
+ class_eval <<RUBY, __FILE__, __LINE__ + 1
13
+ def #{name}(name)
14
+ @#{name}s[name] || @parent && @parent.#{name}(name)
15
+ end
16
+
17
+ def set_#{name}(name, value)
18
+ if @parent && @parent.#{name}(name)
19
+ @parent.set_#{name}(name, value)
20
+ else
21
+ @#{name}s[name] = value
22
+ end
23
+ end
24
+
25
+ def set_local_#{name}(name, value)
26
+ @#{name}s[name] = value
27
+ end
28
+ RUBY
29
+ end
30
+ inherited_hash :var
31
+ inherited_hash :mixin
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ module Sass
2
+ # Sass::SyntaxError encapsulates information about the exception,
3
+ # such as the line of the Sass template it was raised on
4
+ # and the Sass file that was being parsed (if applicable).
5
+ # It also provides a handy way to rescue only exceptions raised
6
+ # because of a faulty template.
7
+ class SyntaxError < StandardError
8
+ # The line of the Sass template on which the exception was thrown.
9
+ attr_accessor :sass_line
10
+
11
+ # The name of the file that was being parsed when the exception was raised.
12
+ # This will be nil unless Sass is being used as an ActionView plugin.
13
+ attr_reader :sass_filename
14
+
15
+ # Creates a new SyntaxError.
16
+ # +lineno+ should be the line of the Sass template on which the error occurred.
17
+ def initialize(msg, lineno = nil)
18
+ @message = msg
19
+ @sass_line = lineno
20
+ end
21
+
22
+ # Adds a properly formatted entry to the exception's backtrace.
23
+ # +filename+ should be the file in which the error occurred,
24
+ # if applicable (defaults to "(sass)").
25
+ def add_backtrace_entry(filename) # :nodoc:
26
+ @sass_filename ||= filename
27
+ self.backtrace ||= []
28
+ self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}"
29
+ end
30
+
31
+ def to_s # :nodoc:
32
+ @message
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,203 @@
1
+ require 'sass/engine'
2
+ require 'pathname'
3
+
4
+ module Sass
5
+ # This module contains methods to aid in using Sass
6
+ # as a stylesheet-rendering plugin for various systems.
7
+ # Currently Rails/ActionController and Merb are supported out of the box.
8
+ module Plugin
9
+ class << self
10
+ @@options = {
11
+ :css_location => './public/stylesheets',
12
+ :always_update => false,
13
+ :always_check => true,
14
+ :full_exception => true
15
+ }
16
+ @@checked_for_updates = false
17
+
18
+ # Whether or not Sass has *ever* checked if the stylesheets need updates
19
+ # (in this Ruby instance).
20
+ def checked_for_updates
21
+ @@checked_for_updates
22
+ end
23
+
24
+ # Gets various options for Sass. See README.rdoc for details.
25
+ #--
26
+ # TODO: *DOCUMENT OPTIONS*
27
+ #++
28
+ def options
29
+ @@options
30
+ end
31
+
32
+ # Sets various options for Sass.
33
+ def options=(value)
34
+ @@options.merge!(value)
35
+ end
36
+
37
+ # Get the options ready to be passed to the Sass::Engine
38
+ def engine_options(additional_options = {})
39
+ opts = options.dup.merge(additional_options)
40
+ opts[:load_paths] = load_paths(opts)
41
+ opts
42
+ end
43
+
44
+ # Checks each stylesheet in <tt>options[:css_location]</tt>
45
+ # to see if it needs updating,
46
+ # and updates it using the corresponding template
47
+ # from <tt>options[:templates]</tt>
48
+ # if it does.
49
+ def update_stylesheets
50
+ return if options[:never_update]
51
+
52
+ @@checked_for_updates = true
53
+ template_locations.zip(css_locations).each do |template_location, css_location|
54
+
55
+ Dir.glob(File.join(template_location, "**", "*.sass")).each do |file|
56
+ # Get the relative path to the file with no extension
57
+ name = file.sub(template_location + "/", "")[0...-5]
58
+
59
+ if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location))
60
+ update_stylesheet(name, template_location, css_location)
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ def update_stylesheet(name, template_location, css_location)
69
+ css = css_filename(name, css_location)
70
+ File.delete(css) if File.exists?(css)
71
+
72
+ filename = template_filename(name, template_location)
73
+ engine = Engine.new(File.read(filename), engine_options(:css_filename => css, :filename => filename))
74
+ result = begin
75
+ engine.render
76
+ rescue Exception => e
77
+ exception_string(e)
78
+ end
79
+
80
+ # Create any directories that might be necessary
81
+ mkpath(css_location, name)
82
+
83
+ # Finally, write the file
84
+ File.open(css, 'w') do |file|
85
+ file.print(result)
86
+ end
87
+ end
88
+
89
+ # Create any successive directories required to be able to write a file to: File.join(base,name)
90
+ def mkpath(base, name)
91
+ dirs = [base]
92
+ name.split(File::SEPARATOR)[0...-1].each { |dir| dirs << File.join(dirs[-1],dir) }
93
+ dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
94
+ end
95
+
96
+ def load_paths(opts = options)
97
+ (opts[:load_paths] || []) + template_locations
98
+ end
99
+
100
+ def template_locations
101
+ location = (options[:template_location] || File.join(options[:css_location],'sass'))
102
+ if location.is_a?(String)
103
+ [location]
104
+ else
105
+ location.to_a.map { |l| l.first }
106
+ end
107
+ end
108
+
109
+ def css_locations
110
+ if options[:template_location] && !options[:template_location].is_a?(String)
111
+ options[:template_location].to_a.map { |l| l.last }
112
+ else
113
+ [options[:css_location]]
114
+ end
115
+ end
116
+
117
+ def exception_string(e)
118
+ if options[:full_exception]
119
+ e_string = "#{e.class}: #{e.message}"
120
+
121
+ if e.is_a? Sass::SyntaxError
122
+ e_string << "\non line #{e.sass_line}"
123
+
124
+ if e.sass_filename
125
+ e_string << " of #{e.sass_filename}"
126
+
127
+ if File.exists?(e.sass_filename)
128
+ e_string << "\n\n"
129
+
130
+ min = [e.sass_line - 5, 0].max
131
+ begin
132
+ File.read(e.sass_filename).rstrip.split("\n")[
133
+ min .. e.sass_line + 5
134
+ ].each_with_index do |line, i|
135
+ e_string << "#{min + i + 1}: #{line}\n"
136
+ end
137
+ rescue
138
+ e_string << "Couldn't read sass file: #{e.sass_filename}"
139
+ end
140
+ end
141
+ end
142
+ end
143
+ <<END
144
+ /*
145
+ #{e_string}
146
+
147
+ Backtrace:\n#{e.backtrace.join("\n")}
148
+ */
149
+ body:before {
150
+ white-space: pre;
151
+ font-family: monospace;
152
+ content: "#{e_string.gsub('"', '\"').gsub("\n", '\\A ')}"; }
153
+ END
154
+ # Fix an emacs syntax-highlighting hiccup: '
155
+ else
156
+ "/* Internal stylesheet error */"
157
+ end
158
+ end
159
+
160
+ def template_filename(name, path)
161
+ "#{path}/#{name}.sass"
162
+ end
163
+
164
+ def css_filename(name, path)
165
+ "#{path}/#{name}.css"
166
+ end
167
+
168
+ def forbid_update?(name)
169
+ name.sub(/^.*\//, '')[0] == ?_
170
+ end
171
+
172
+ def stylesheet_needs_update?(name, template_path, css_path)
173
+ css_file = css_filename(name, css_path)
174
+ template_file = template_filename(name, template_path)
175
+ if !File.exists?(css_file)
176
+ return true
177
+ else
178
+ css_mtime = File.mtime(css_file)
179
+ File.mtime(template_file) > css_mtime ||
180
+ dependencies(template_file).any?(&dependency_updated?(css_mtime))
181
+ end
182
+ end
183
+
184
+ def dependency_updated?(css_mtime)
185
+ lambda do |dep|
186
+ File.mtime(dep) > css_mtime ||
187
+ dependencies(dep).any?(&dependency_updated?(css_mtime))
188
+ end
189
+ end
190
+
191
+ def dependencies(filename)
192
+ File.readlines(filename).grep(/^@import /).map do |line|
193
+ line[8..-1].split(',').map do |inc|
194
+ Sass::Engine.find_file_to_import(inc.strip, [File.dirname(filename)] + load_paths)
195
+ end
196
+ end.flatten.grep(/\.sass$/)
197
+ end
198
+ end
199
+ end
200
+ end
201
+
202
+ require 'sass/plugin/rails' if defined?(ActionController)
203
+ require 'sass/plugin/merb' if defined?(Merb::Plugins)
@@ -0,0 +1,56 @@
1
+ unless defined?(Sass::MERB_LOADED)
2
+ Sass::MERB_LOADED = true
3
+
4
+ version = Merb::VERSION.split('.').map { |n| n.to_i }
5
+ if version[0] <= 0 && version[1] < 5
6
+ root = MERB_ROOT
7
+ env = MERB_ENV
8
+ else
9
+ root = Merb.root.to_s
10
+ env = Merb.environment
11
+ end
12
+
13
+ Sass::Plugin.options.merge!(:template_location => root + '/public/stylesheets/sass',
14
+ :css_location => root + '/public/stylesheets',
15
+ :always_check => env != "production",
16
+ :full_exception => env != "production")
17
+ config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
18
+
19
+ if defined? config.symbolize_keys!
20
+ config.symbolize_keys!
21
+ end
22
+
23
+ Sass::Plugin.options.merge!(config)
24
+
25
+ if version[0] > 0 || version[1] >= 9
26
+
27
+ class Merb::Rack::Application # :nodoc:
28
+ def call_with_sass(env)
29
+ if !Sass::Plugin.checked_for_updates ||
30
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
31
+ Sass::Plugin.update_stylesheets
32
+ end
33
+
34
+ call_without_sass(env)
35
+ end
36
+ alias_method :call_without_sass, :call
37
+ alias_method :call, :call_with_sass
38
+ end
39
+
40
+ else
41
+
42
+ class MerbHandler # :nodoc:
43
+ def process_with_sass(request, response)
44
+ if !Sass::Plugin.checked_for_updates ||
45
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
46
+ Sass::Plugin.update_stylesheets
47
+ end
48
+
49
+ process_without_sass(request, response)
50
+ end
51
+ alias_method :process_without_sass, :process
52
+ alias_method :process, :process_with_sass
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ unless defined?(Sass::RAILS_LOADED)
2
+ Sass::RAILS_LOADED = true
3
+
4
+ Sass::Plugin.options.merge!(:template_location => RAILS_ROOT + '/public/stylesheets/sass',
5
+ :css_location => RAILS_ROOT + '/public/stylesheets',
6
+ :always_check => RAILS_ENV != "production",
7
+ :full_exception => RAILS_ENV != "production")
8
+
9
+ # :stopdoc:
10
+ module ActionController
11
+ class Base
12
+ alias_method :sass_old_process, :process
13
+ def process(*args)
14
+ if !Sass::Plugin.checked_for_updates ||
15
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
16
+ Sass::Plugin.update_stylesheets
17
+ end
18
+
19
+ sass_old_process(*args)
20
+ end
21
+ end
22
+ end
23
+ # :startdoc:
24
+ end
@@ -0,0 +1,44 @@
1
+ require 'readline'
2
+
3
+ module Sass
4
+ module Repl
5
+ class << self
6
+ def run
7
+ environment = Environment.new
8
+ environment.set_var('important', Script::String.new('!important'))
9
+ @line = 0
10
+ loop do
11
+ @line += 1
12
+ unless text = Readline.readline('>> ')
13
+ puts
14
+ return
15
+ end
16
+
17
+ Readline::HISTORY << text
18
+ parse_input(environment, text)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def parse_input(environment, text)
25
+ case text
26
+ when Script::MATCH
27
+ name = $1
28
+ guarded = $2 == '||='
29
+ val = Script::Parser.parse($3, @line, text.size - $3.size)
30
+
31
+ unless guarded && environment.var(name)
32
+ environment.set_var(name, val.perform(environment))
33
+ end
34
+
35
+ p environment.var(name)
36
+ else
37
+ p Script::Parser.parse(text, @line, 0).perform(environment)
38
+ end
39
+ rescue Sass::SyntaxError => e
40
+ puts "SyntaxError: #{e.message}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ require 'strscan'
2
+ require 'sass/script/variable'
3
+ require 'sass/script/funcall'
4
+ require 'sass/script/operation'
5
+ require 'sass/script/literal'
6
+ require 'sass/script/parser'
7
+
8
+ module Sass
9
+ # This module contains various SassScript-related functionality.
10
+ module Script
11
+ # :stopdoc:
12
+ # The character that begins a variable.
13
+ VARIABLE_CHAR = ?!
14
+
15
+ # The regular expression used to parse variables
16
+ MATCH = /^!(\w+)\s*((?:\|\|)?=)\s*(.+)/
17
+
18
+ # The regular expression used to validate variables without matching
19
+ VALIDATE = /^!\w+$/
20
+
21
+ def self.resolve(value, line, offset, environment)
22
+ parse(value, line, offset).perform(environment).to_s
23
+ end
24
+
25
+ def self.parse(value, line, offset, filename = nil)
26
+ Parser.parse(value, line, offset, filename)
27
+ rescue Sass::SyntaxError => e
28
+ if e.message == "SassScript error"
29
+ e.instance_eval do
30
+ @message += ": #{value.dump}."
31
+ end
32
+ end
33
+ e.sass_line = line
34
+ raise e
35
+ end
36
+ # :startdoc:
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ require 'sass/script/literal'
2
+
3
+ module Sass::Script
4
+ class Bool < Literal # :nodoc:
5
+ def to_s
6
+ @value.to_s
7
+ end
8
+
9
+ def to_bool
10
+ @value
11
+ end
12
+ end
13
+ end