haml 3.0.25 → 3.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +1 -1
- data/CONTRIBUTING +0 -1
- data/EDGE_GEM_VERSION +1 -0
- data/MIT-LICENSE +1 -1
- data/README.md +10 -175
- data/Rakefile +56 -84
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/init.rb +1 -1
- data/lib/haml.rb +14 -12
- data/lib/haml/engine.rb +1 -1
- data/lib/haml/exec.rb +19 -316
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/html.rb +69 -76
- data/lib/haml/precompiler.rb +34 -41
- data/lib/haml/railtie.rb +4 -6
- data/lib/haml/template/plugin.rb +6 -16
- data/lib/haml/util.rb +91 -107
- data/lib/haml/version.rb +7 -0
- data/test/benchmark.rb +2 -9
- data/test/haml/engine_test.rb +195 -92
- data/test/haml/html2haml/erb_tests.rb +0 -14
- data/test/haml/util_test.rb +32 -0
- data/test/test_helper.rb +0 -39
- metadata +96 -324
- data/bin/css2sass +0 -13
- data/bin/sass +0 -8
- data/bin/sass-convert +0 -7
- data/extra/haml-mode.el +0 -753
- data/extra/sass-mode.el +0 -207
- data/lib/haml/util/subset_map.rb +0 -101
- data/lib/sass.rb +0 -29
- data/lib/sass/callbacks.rb +0 -52
- data/lib/sass/css.rb +0 -294
- data/lib/sass/engine.rb +0 -720
- data/lib/sass/environment.rb +0 -143
- data/lib/sass/error.rb +0 -198
- data/lib/sass/files.rb +0 -160
- data/lib/sass/less.rb +0 -382
- data/lib/sass/plugin.rb +0 -279
- data/lib/sass/plugin/configuration.rb +0 -221
- data/lib/sass/plugin/generic.rb +0 -15
- data/lib/sass/plugin/merb.rb +0 -37
- data/lib/sass/plugin/rack.rb +0 -47
- data/lib/sass/plugin/rails.rb +0 -32
- data/lib/sass/plugin/staleness_checker.rb +0 -123
- data/lib/sass/repl.rb +0 -58
- data/lib/sass/script.rb +0 -63
- data/lib/sass/script/bool.rb +0 -18
- data/lib/sass/script/color.rb +0 -491
- data/lib/sass/script/css_lexer.rb +0 -29
- data/lib/sass/script/css_parser.rb +0 -31
- data/lib/sass/script/funcall.rb +0 -77
- data/lib/sass/script/functions.rb +0 -861
- data/lib/sass/script/interpolation.rb +0 -70
- data/lib/sass/script/lexer.rb +0 -337
- data/lib/sass/script/literal.rb +0 -236
- data/lib/sass/script/node.rb +0 -112
- data/lib/sass/script/number.rb +0 -423
- data/lib/sass/script/operation.rb +0 -95
- data/lib/sass/script/parser.rb +0 -401
- data/lib/sass/script/string.rb +0 -67
- data/lib/sass/script/string_interpolation.rb +0 -93
- data/lib/sass/script/unary_operation.rb +0 -57
- data/lib/sass/script/variable.rb +0 -48
- data/lib/sass/scss.rb +0 -17
- data/lib/sass/scss/css_parser.rb +0 -46
- data/lib/sass/scss/parser.rb +0 -855
- data/lib/sass/scss/rx.rb +0 -126
- data/lib/sass/scss/sass_parser.rb +0 -11
- data/lib/sass/scss/script_lexer.rb +0 -15
- data/lib/sass/scss/script_parser.rb +0 -25
- data/lib/sass/scss/static_parser.rb +0 -40
- data/lib/sass/selector.rb +0 -361
- data/lib/sass/selector/abstract_sequence.rb +0 -62
- data/lib/sass/selector/comma_sequence.rb +0 -82
- data/lib/sass/selector/sequence.rb +0 -237
- data/lib/sass/selector/simple.rb +0 -113
- data/lib/sass/selector/simple_sequence.rb +0 -136
- data/lib/sass/tree/charset_node.rb +0 -37
- data/lib/sass/tree/comment_node.rb +0 -128
- data/lib/sass/tree/debug_node.rb +0 -36
- data/lib/sass/tree/directive_node.rb +0 -75
- data/lib/sass/tree/extend_node.rb +0 -65
- data/lib/sass/tree/for_node.rb +0 -55
- data/lib/sass/tree/if_node.rb +0 -69
- data/lib/sass/tree/import_node.rb +0 -102
- data/lib/sass/tree/mixin_def_node.rb +0 -48
- data/lib/sass/tree/mixin_node.rb +0 -111
- data/lib/sass/tree/node.rb +0 -464
- data/lib/sass/tree/prop_node.rb +0 -220
- data/lib/sass/tree/root_node.rb +0 -163
- data/lib/sass/tree/rule_node.rb +0 -261
- data/lib/sass/tree/variable_node.rb +0 -39
- data/lib/sass/tree/warn_node.rb +0 -42
- data/lib/sass/tree/while_node.rb +0 -36
- data/test/haml/util/subset_map_test.rb +0 -91
- data/test/sass/callbacks_test.rb +0 -61
- data/test/sass/conversion_test.rb +0 -1218
- data/test/sass/css2sass_test.rb +0 -364
- data/test/sass/data/hsl-rgb.txt +0 -319
- data/test/sass/engine_test.rb +0 -2267
- data/test/sass/extend_test.rb +0 -1348
- data/test/sass/functions_test.rb +0 -556
- data/test/sass/less_conversion_test.rb +0 -653
- data/test/sass/more_results/more1.css +0 -9
- data/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/test/sass/more_results/more_import.css +0 -29
- data/test/sass/more_templates/_more_partial.sass +0 -2
- data/test/sass/more_templates/more1.sass +0 -23
- data/test/sass/more_templates/more_import.sass +0 -11
- data/test/sass/plugin_test.rb +0 -433
- data/test/sass/results/alt.css +0 -4
- data/test/sass/results/basic.css +0 -9
- data/test/sass/results/compact.css +0 -5
- data/test/sass/results/complex.css +0 -86
- data/test/sass/results/compressed.css +0 -1
- data/test/sass/results/expanded.css +0 -19
- data/test/sass/results/import.css +0 -31
- data/test/sass/results/import_charset.css +0 -4
- data/test/sass/results/import_charset_1_8.css +0 -4
- data/test/sass/results/import_charset_ibm866.css +0 -4
- data/test/sass/results/line_numbers.css +0 -49
- data/test/sass/results/mixins.css +0 -95
- data/test/sass/results/multiline.css +0 -24
- data/test/sass/results/nested.css +0 -22
- data/test/sass/results/options.css +0 -1
- data/test/sass/results/parent_ref.css +0 -13
- data/test/sass/results/script.css +0 -16
- data/test/sass/results/scss_import.css +0 -31
- data/test/sass/results/scss_importee.css +0 -2
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/test/sass/results/subdir/subdir.css +0 -3
- data/test/sass/results/units.css +0 -11
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +0 -314
- data/test/sass/script_test.rb +0 -470
- data/test/sass/scss/css_test.rb +0 -916
- data/test/sass/scss/rx_test.rb +0 -156
- data/test/sass/scss/scss_test.rb +0 -1122
- data/test/sass/scss/test_helper.rb +0 -37
- data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/test/sass/templates/_partial.sass +0 -2
- data/test/sass/templates/alt.sass +0 -16
- data/test/sass/templates/basic.sass +0 -23
- data/test/sass/templates/bork1.sass +0 -2
- data/test/sass/templates/bork2.sass +0 -2
- data/test/sass/templates/bork3.sass +0 -2
- data/test/sass/templates/bork4.sass +0 -2
- data/test/sass/templates/compact.sass +0 -17
- data/test/sass/templates/complex.sass +0 -305
- data/test/sass/templates/compressed.sass +0 -15
- data/test/sass/templates/expanded.sass +0 -17
- data/test/sass/templates/import.sass +0 -12
- data/test/sass/templates/import_charset.sass +0 -7
- data/test/sass/templates/import_charset_1_8.sass +0 -4
- data/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/test/sass/templates/importee.less +0 -2
- data/test/sass/templates/importee.sass +0 -19
- data/test/sass/templates/line_numbers.sass +0 -13
- data/test/sass/templates/mixin_bork.sass +0 -5
- data/test/sass/templates/mixins.sass +0 -76
- data/test/sass/templates/multiline.sass +0 -20
- data/test/sass/templates/nested.sass +0 -25
- data/test/sass/templates/nested_bork1.sass +0 -2
- data/test/sass/templates/nested_bork2.sass +0 -2
- data/test/sass/templates/nested_bork3.sass +0 -2
- data/test/sass/templates/nested_bork4.sass +0 -2
- data/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/test/sass/templates/options.sass +0 -2
- data/test/sass/templates/parent_ref.sass +0 -25
- data/test/sass/templates/script.sass +0 -101
- data/test/sass/templates/scss_import.scss +0 -11
- data/test/sass/templates/scss_importee.scss +0 -1
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/test/sass/templates/subdir/subdir.sass +0 -6
- data/test/sass/templates/units.sass +0 -11
- data/test/sass/templates/warn.sass +0 -3
- data/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm.rb +0 -33
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/path_spec.rb +0 -75
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.1.0.alpha.2
|
data/VERSION_NAME
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Bleeding Edge
|
data/init.rb
CHANGED
data/lib/haml.rb
CHANGED
@@ -13,13 +13,6 @@ require 'haml/version'
|
|
13
13
|
#
|
14
14
|
# Also see the {file:HAML_REFERENCE.md full Haml reference}.
|
15
15
|
module Haml
|
16
|
-
extend Haml::Version
|
17
|
-
|
18
|
-
# A string representing the version of Haml.
|
19
|
-
# A more fine-grained representation is available from Haml.version.
|
20
|
-
# @api public
|
21
|
-
VERSION = version[:string] unless defined?(Haml::VERSION)
|
22
|
-
|
23
16
|
# Initializes Haml for Rails.
|
24
17
|
#
|
25
18
|
# This method is called by `init.rb`,
|
@@ -32,13 +25,22 @@ module Haml
|
|
32
25
|
# This isn't actually used;
|
33
26
|
# it's just passed in in case it needs to be used in the future
|
34
27
|
def self.init_rails(binding)
|
28
|
+
# Rails 2.2+
|
29
|
+
if defined?(Rails) && Rails.respond_to?(:configuration) &&
|
30
|
+
Rails.configuration.respond_to?(:after_initialize)
|
31
|
+
Rails.configuration.after_initialize do
|
32
|
+
next if defined?(Sass)
|
33
|
+
autoload(:Sass, 'sass/rails2_shim')
|
34
|
+
# resolve autoload if it looks like they're using Sass without options
|
35
|
+
Sass if File.exist?(File.join(RAILS_ROOT, 'public/stylesheets/sass'))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
35
39
|
# No &method here for Rails 2.1 compatibility
|
36
|
-
%w[haml/template
|
40
|
+
%w[haml/template].each {|f| require f}
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
44
|
require 'haml/util'
|
41
|
-
|
42
|
-
|
43
|
-
require 'haml/railtie'
|
44
|
-
end
|
45
|
+
require 'haml/engine'
|
46
|
+
require 'haml/railtie'
|
data/lib/haml/engine.rb
CHANGED
data/lib/haml/exec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'optparse'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
module Haml
|
5
|
-
# This module handles the various Haml executables (`haml
|
5
|
+
# This module handles the various Haml executables (`haml` and `haml-convert`).
|
6
6
|
module Exec
|
7
7
|
# An abstract class that encapsulates the executable code for all three executables.
|
8
8
|
class Generic
|
@@ -89,7 +89,7 @@ module Haml
|
|
89
89
|
end
|
90
90
|
|
91
91
|
opts.on_tail("-v", "--version", "Print version") do
|
92
|
-
puts("Haml
|
92
|
+
puts("Haml #{::Haml.version[:string]}")
|
93
93
|
exit
|
94
94
|
end
|
95
95
|
end
|
@@ -124,18 +124,9 @@ module Haml
|
|
124
124
|
# @param color [Symbol] The name of the color to use for this action.
|
125
125
|
# Can be `:red`, `:green`, or `:yellow`.
|
126
126
|
def puts_action(name, color, arg)
|
127
|
-
return if @options[:for_engine][:quiet]
|
128
127
|
printf color(color, "%11s %s\n"), name, arg
|
129
128
|
end
|
130
129
|
|
131
|
-
# Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
|
132
|
-
#
|
133
|
-
# @param args [Array] Passed on to \{Kernel.puts}
|
134
|
-
def puts(*args)
|
135
|
-
return if @options[:for_engine][:quiet]
|
136
|
-
Kernel.puts(*args)
|
137
|
-
end
|
138
|
-
|
139
130
|
# Wraps the given string in terminal escapes
|
140
131
|
# causing it to have the given color.
|
141
132
|
# If terminal esapes aren't supported on this platform,
|
@@ -164,7 +155,7 @@ module Haml
|
|
164
155
|
end
|
165
156
|
|
166
157
|
def handle_load_error(err)
|
167
|
-
dep = err.message
|
158
|
+
dep = err.message.scan(/^no such file to load -- (.*)/)[0]
|
168
159
|
raise err if @options[:trace] || dep.nil? || dep.empty?
|
169
160
|
$stderr.puts <<MESSAGE
|
170
161
|
Required dependency #{dep} not found!
|
@@ -175,329 +166,37 @@ MESSAGE
|
|
175
166
|
end
|
176
167
|
end
|
177
168
|
|
178
|
-
#
|
179
|
-
|
180
|
-
class HamlSass < Generic
|
169
|
+
# The `haml` executable.
|
170
|
+
class Haml < Generic
|
181
171
|
# @param args [Array<String>] The command-line arguments
|
182
172
|
def initialize(args)
|
183
173
|
super
|
184
174
|
@options[:for_engine] = {}
|
175
|
+
@options[:requires] = []
|
176
|
+
@options[:load_paths] = []
|
185
177
|
end
|
186
178
|
|
187
|
-
|
188
|
-
|
189
|
-
# Tells optparse how to parse the arguments
|
190
|
-
# available for the `haml` and `sass` executables.
|
191
|
-
#
|
192
|
-
# This is meant to be overridden by subclasses
|
193
|
-
# so they can add their own options.
|
179
|
+
# Tells optparse how to parse the arguments.
|
194
180
|
#
|
195
181
|
# @param opts [OptionParser]
|
196
182
|
def set_opts(opts)
|
183
|
+
super
|
184
|
+
|
197
185
|
opts.banner = <<END
|
198
|
-
Usage:
|
186
|
+
Usage: haml [options] [INPUT] [OUTPUT]
|
199
187
|
|
200
188
|
Description:
|
201
|
-
|
202
|
-
and outputs the result to the specified file.
|
189
|
+
Converts Haml files to HTML.
|
203
190
|
|
204
191
|
Options:
|
205
192
|
END
|
206
193
|
|
207
|
-
opts.on('--rails RAILS_DIR', "Install Haml and Sass from the Gem to a Rails project") do |dir|
|
208
|
-
original_dir = dir
|
209
|
-
|
210
|
-
env = File.join(dir, "config", "environment.rb")
|
211
|
-
if File.exists?(File.join(dir, "Gemfile"))
|
212
|
-
puts("haml --rails isn't needed for Rails 3 or greater.",
|
213
|
-
"Add 'gem \"haml\"' to your Gemfile instead.", "",
|
214
|
-
"haml --rails will no longer work in the next version of #{@name}.", "")
|
215
|
-
elsif File.exists?(env) && File.open(env) {|env| env.grep(/config\.gem/)}
|
216
|
-
puts("haml --rails isn't needed for Rails 2.1 or greater.",
|
217
|
-
"Add 'config.gem \"haml\"' to config/environment.rb instead.", "",
|
218
|
-
"haml --rails will no longer work in the next version of #{@name}.", "")
|
219
|
-
end
|
220
|
-
|
221
|
-
dir = File.join(dir, 'vendor', 'plugins')
|
222
|
-
|
223
|
-
unless File.exists?(dir)
|
224
|
-
puts "Directory #{dir} doesn't exist"
|
225
|
-
exit 1
|
226
|
-
end
|
227
|
-
|
228
|
-
dir = File.join(dir, 'haml')
|
229
|
-
|
230
|
-
if File.exists?(dir)
|
231
|
-
print "Directory #{dir} already exists, overwrite [y/N]? "
|
232
|
-
exit 2 if gets !~ /y/i
|
233
|
-
FileUtils.rm_rf(dir)
|
234
|
-
end
|
235
|
-
|
236
|
-
begin
|
237
|
-
Dir.mkdir(dir)
|
238
|
-
rescue SystemCallError
|
239
|
-
puts "Cannot create #{dir}"
|
240
|
-
exit 1
|
241
|
-
end
|
242
|
-
|
243
|
-
File.open(File.join(dir, 'init.rb'), 'w') do |file|
|
244
|
-
file << File.read(File.dirname(__FILE__) + "/../../init.rb")
|
245
|
-
end
|
246
|
-
|
247
|
-
puts "Haml plugin added to #{original_dir}"
|
248
|
-
exit
|
249
|
-
end
|
250
|
-
|
251
194
|
opts.on('-c', '--check', "Just check syntax, don't evaluate.") do
|
252
195
|
require 'stringio'
|
253
196
|
@options[:check_syntax] = true
|
254
197
|
@options[:output] = StringIO.new
|
255
198
|
end
|
256
199
|
|
257
|
-
super
|
258
|
-
end
|
259
|
-
|
260
|
-
# Processes the options set by the command-line arguments.
|
261
|
-
# In particular, sets `@options[:for_engine][:filename]` to the input filename
|
262
|
-
# and requires the appropriate file.
|
263
|
-
#
|
264
|
-
# This is meant to be overridden by subclasses
|
265
|
-
# so they can run their respective programs.
|
266
|
-
def process_result
|
267
|
-
super
|
268
|
-
@options[:for_engine][:filename] = @options[:filename] if @options[:filename]
|
269
|
-
require File.dirname(__FILE__) + "/../#{@name.downcase}"
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
# The `sass` executable.
|
274
|
-
class Sass < HamlSass
|
275
|
-
# @param args [Array<String>] The command-line arguments
|
276
|
-
def initialize(args)
|
277
|
-
super
|
278
|
-
@name = "Sass"
|
279
|
-
@options[:for_engine][:load_paths] = ['.'] + (ENV['SASSPATH'] || '').split(File::PATH_SEPARATOR)
|
280
|
-
end
|
281
|
-
|
282
|
-
protected
|
283
|
-
|
284
|
-
# Tells optparse how to parse the arguments.
|
285
|
-
#
|
286
|
-
# @param opts [OptionParser]
|
287
|
-
def set_opts(opts)
|
288
|
-
super
|
289
|
-
|
290
|
-
opts.on('--scss',
|
291
|
-
'Use the CSS-superset SCSS syntax.') do
|
292
|
-
@options[:for_engine][:syntax] = :scss
|
293
|
-
end
|
294
|
-
opts.on('--watch', 'Watch files or directories for changes.',
|
295
|
-
'The location of the generated CSS can be set using a colon:',
|
296
|
-
' sass --watch input.sass:output.css',
|
297
|
-
' sass --watch input-dir:output-dir') do
|
298
|
-
@options[:watch] = true
|
299
|
-
end
|
300
|
-
opts.on('--update', 'Compile files or directories to CSS.',
|
301
|
-
'Locations are set like --watch.') do
|
302
|
-
@options[:update] = true
|
303
|
-
end
|
304
|
-
opts.on('--stop-on-error', 'If a file fails to compile, exit immediately.',
|
305
|
-
'Only meaningful for --watch and --update.') do
|
306
|
-
@options[:stop_on_error] = true
|
307
|
-
end
|
308
|
-
opts.on('-t', '--style NAME',
|
309
|
-
'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
|
310
|
-
@options[:for_engine][:style] = name.to_sym
|
311
|
-
end
|
312
|
-
opts.on('-q', '--quiet', 'Silence warnings and status messages during compilation.') do
|
313
|
-
@options[:for_engine][:quiet] = true
|
314
|
-
end
|
315
|
-
opts.on('-g', '--debug-info',
|
316
|
-
'Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.') do
|
317
|
-
@options[:for_engine][:debug_info] = true
|
318
|
-
end
|
319
|
-
opts.on('-l', '--line-numbers', '--line-comments',
|
320
|
-
'Emit comments in the generated CSS indicating the corresponding sass line.') do
|
321
|
-
@options[:for_engine][:line_numbers] = true
|
322
|
-
end
|
323
|
-
opts.on('-i', '--interactive',
|
324
|
-
'Run an interactive SassScript shell.') do
|
325
|
-
@options[:interactive] = true
|
326
|
-
end
|
327
|
-
opts.on('-I', '--load-path PATH', 'Add a sass import path.') do |path|
|
328
|
-
@options[:for_engine][:load_paths] << path
|
329
|
-
end
|
330
|
-
opts.on('-r', '--require LIB', 'Require a Ruby library before running Sass.') do |lib|
|
331
|
-
require lib
|
332
|
-
end
|
333
|
-
opts.on('--cache-location PATH', 'The path to put cached Sass files. Defaults to .sass-cache.') do |loc|
|
334
|
-
@options[:for_engine][:cache_location] = loc
|
335
|
-
end
|
336
|
-
opts.on('-C', '--no-cache', "Don't cache to sassc files.") do
|
337
|
-
@options[:for_engine][:cache] = false
|
338
|
-
end
|
339
|
-
|
340
|
-
unless ::Haml::Util.ruby1_8?
|
341
|
-
opts.on('-E encoding', 'Specify the default encoding for Sass files.') do |encoding|
|
342
|
-
Encoding.default_external = encoding
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
# Processes the options set by the command-line arguments,
|
348
|
-
# and runs the Sass compiler appropriately.
|
349
|
-
def process_result
|
350
|
-
if !@options[:update] && !@options[:watch] &&
|
351
|
-
@args.first && colon_path?(@args.first)
|
352
|
-
if @args.size == 1
|
353
|
-
@args = split_colon_path(@args.first)
|
354
|
-
else
|
355
|
-
@options[:update] = true
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
return interactive if @options[:interactive]
|
360
|
-
return watch_or_update if @options[:watch] || @options[:update]
|
361
|
-
super
|
362
|
-
|
363
|
-
begin
|
364
|
-
input = @options[:input]
|
365
|
-
output = @options[:output]
|
366
|
-
|
367
|
-
@options[:for_engine][:syntax] ||= :scss if input.is_a?(File) && input.path =~ /\.scss$/
|
368
|
-
tree =
|
369
|
-
if input.is_a?(File) && !@options[:check_syntax]
|
370
|
-
::Sass::Files.tree_for(input.path, @options[:for_engine])
|
371
|
-
else
|
372
|
-
# We don't need to do any special handling of @options[:check_syntax] here,
|
373
|
-
# because the Sass syntax checking happens alongside evaluation
|
374
|
-
# and evaluation doesn't actually evaluate any code anyway.
|
375
|
-
::Sass::Engine.new(input.read(), @options[:for_engine]).to_tree
|
376
|
-
end
|
377
|
-
|
378
|
-
input.close() if input.is_a?(File)
|
379
|
-
|
380
|
-
output.write(tree.render)
|
381
|
-
output.close() if output.is_a? File
|
382
|
-
rescue ::Sass::SyntaxError => e
|
383
|
-
raise e if @options[:trace]
|
384
|
-
raise e.sass_backtrace_str("standard input")
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
private
|
389
|
-
|
390
|
-
def interactive
|
391
|
-
require 'sass'
|
392
|
-
require 'sass/repl'
|
393
|
-
::Sass::Repl.new(@options).run
|
394
|
-
end
|
395
|
-
|
396
|
-
def watch_or_update
|
397
|
-
require 'sass'
|
398
|
-
require 'sass/plugin'
|
399
|
-
::Sass::Plugin.options.merge! @options[:for_engine]
|
400
|
-
::Sass::Plugin.options[:unix_newlines] = @options[:unix_newlines]
|
401
|
-
|
402
|
-
raise <<MSG if @args.empty?
|
403
|
-
What files should I watch? Did you mean something like:
|
404
|
-
sass --watch input.sass:output.css
|
405
|
-
sass --watch input-dir:output-dir
|
406
|
-
MSG
|
407
|
-
|
408
|
-
if !colon_path?(@args[0]) && probably_dest_dir?(@args[1])
|
409
|
-
flag = @options[:update] ? "--update" : "--watch"
|
410
|
-
err =
|
411
|
-
if !File.exist?(@args[1])
|
412
|
-
"doesn't exist"
|
413
|
-
elsif @args[1] =~ /\.css$/
|
414
|
-
"is a CSS file"
|
415
|
-
end
|
416
|
-
raise <<MSG if err
|
417
|
-
File #{@args[1]} #{err}.
|
418
|
-
Did you mean: sass #{flag} #{@args[0]}:#{@args[1]}
|
419
|
-
MSG
|
420
|
-
end
|
421
|
-
|
422
|
-
dirs, files = @args.map {|name| split_colon_path(name)}.
|
423
|
-
partition {|i, _| File.directory? i}
|
424
|
-
files.map! {|from, to| [from, to || from.gsub(/\..*?$/, '.css')]}
|
425
|
-
dirs.map! {|from, to| [from, to || from]}
|
426
|
-
::Sass::Plugin.options[:template_location] = dirs
|
427
|
-
|
428
|
-
::Sass::Plugin.on_updating_stylesheet do |_, css|
|
429
|
-
if File.exists? css
|
430
|
-
puts_action :overwrite, :yellow, css
|
431
|
-
else
|
432
|
-
puts_action :create, :green, css
|
433
|
-
end
|
434
|
-
end
|
435
|
-
|
436
|
-
had_error = false
|
437
|
-
::Sass::Plugin.on_creating_directory {|dirname| puts_action :directory, :green, dirname}
|
438
|
-
::Sass::Plugin.on_deleting_css {|filename| puts_action :delete, :yellow, filename}
|
439
|
-
::Sass::Plugin.on_compilation_error do |error, _, _|
|
440
|
-
raise error unless error.is_a?(::Sass::SyntaxError) && !@options[:stop_on_error]
|
441
|
-
had_error = true
|
442
|
-
puts_action :error, :red, "#{error.sass_filename} (Line #{error.sass_line}: #{error.message})"
|
443
|
-
end
|
444
|
-
|
445
|
-
if @options[:update]
|
446
|
-
::Sass::Plugin.update_stylesheets(files)
|
447
|
-
exit 1 if had_error
|
448
|
-
return
|
449
|
-
end
|
450
|
-
|
451
|
-
puts ">>> Sass is watching for changes. Press Ctrl-C to stop."
|
452
|
-
|
453
|
-
::Sass::Plugin.on_template_modified {|template| puts ">>> Change detected to: #{template}"}
|
454
|
-
::Sass::Plugin.on_template_created {|template| puts ">>> New template detected: #{template}"}
|
455
|
-
::Sass::Plugin.on_template_deleted {|template| puts ">>> Deleted template detected: #{template}"}
|
456
|
-
|
457
|
-
::Sass::Plugin.watch(files)
|
458
|
-
end
|
459
|
-
|
460
|
-
def colon_path?(path)
|
461
|
-
!split_colon_path(path)[1].nil?
|
462
|
-
end
|
463
|
-
|
464
|
-
def split_colon_path(path)
|
465
|
-
one, two = path.split(':', 2)
|
466
|
-
if one && two && ::Haml::Util.windows? &&
|
467
|
-
one =~ /\A[A-Za-z]\Z/ && two =~ /\A[\/\\]/
|
468
|
-
# If we're on Windows and we were passed a drive letter path,
|
469
|
-
# don't split on that colon.
|
470
|
-
one2, two = two.split(':', 2)
|
471
|
-
one = one + ':' + one2
|
472
|
-
end
|
473
|
-
return one, two
|
474
|
-
end
|
475
|
-
|
476
|
-
# Whether path is likely to be meant as the destination
|
477
|
-
# in a source:dest pair.
|
478
|
-
def probably_dest_dir?(path)
|
479
|
-
return false unless path
|
480
|
-
return false if colon_path?(path)
|
481
|
-
return Dir.glob(File.join(path, "*.s[ca]ss")).empty?
|
482
|
-
end
|
483
|
-
end
|
484
|
-
|
485
|
-
# The `haml` executable.
|
486
|
-
class Haml < HamlSass
|
487
|
-
# @param args [Array<String>] The command-line arguments
|
488
|
-
def initialize(args)
|
489
|
-
super
|
490
|
-
@name = "Haml"
|
491
|
-
@options[:requires] = []
|
492
|
-
@options[:load_paths] = []
|
493
|
-
end
|
494
|
-
|
495
|
-
# Tells optparse how to parse the arguments.
|
496
|
-
#
|
497
|
-
# @param opts [OptionParser]
|
498
|
-
def set_opts(opts)
|
499
|
-
super
|
500
|
-
|
501
200
|
opts.on('-t', '--style NAME',
|
502
201
|
'Output style. Can be indented (default) or ugly.') do |name|
|
503
202
|
@options[:for_engine][:ugly] = true if name.to_sym == :ugly
|
@@ -543,6 +242,7 @@ MSG
|
|
543
242
|
# and runs the Haml compiler appropriately.
|
544
243
|
def process_result
|
545
244
|
super
|
245
|
+
@options[:for_engine][:filename] = @options[:filename]
|
546
246
|
input = @options[:input]
|
547
247
|
output = @options[:output]
|
548
248
|
|
@@ -644,6 +344,8 @@ END
|
|
644
344
|
handle_load_error(err)
|
645
345
|
end
|
646
346
|
end
|
347
|
+
<<<<<<< HEAD
|
348
|
+
=======
|
647
349
|
|
648
350
|
# The `sass-convert` executable.
|
649
351
|
class SassConvert < Generic
|
@@ -839,10 +541,10 @@ END
|
|
839
541
|
Less::Engine.new(input).to_tree.to_sass_tree.send("to_#{@options[:to]}", @options[:for_tree])
|
840
542
|
else
|
841
543
|
if input.is_a?(File)
|
842
|
-
::Sass::
|
544
|
+
::Sass::Engine.for_file(input.path, @options[:for_engine])
|
843
545
|
else
|
844
|
-
::Sass::Engine.new(input.read, @options[:for_engine])
|
845
|
-
end.send("to_#{@options[:to]}", @options[:for_tree])
|
546
|
+
::Sass::Engine.new(input.read, @options[:for_engine])
|
547
|
+
end.to_tree.send("to_#{@options[:to]}", @options[:for_tree])
|
846
548
|
end
|
847
549
|
end
|
848
550
|
|
@@ -867,5 +569,6 @@ END
|
|
867
569
|
NOTE
|
868
570
|
end
|
869
571
|
end
|
572
|
+
>>>>>>> master
|
870
573
|
end
|
871
574
|
end
|