haml 2.0.10 → 2.2.0

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.

Files changed (107) hide show
  1. data/.yardopts +5 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +347 -0
  4. data/Rakefile +124 -19
  5. data/VERSION +1 -1
  6. data/VERSION_NAME +1 -0
  7. data/extra/haml-mode.el +397 -78
  8. data/extra/sass-mode.el +148 -36
  9. data/extra/update_watch.rb +13 -0
  10. data/lib/haml.rb +15 -993
  11. data/lib/haml/buffer.rb +131 -84
  12. data/lib/haml/engine.rb +129 -97
  13. data/lib/haml/error.rb +7 -7
  14. data/lib/haml/exec.rb +127 -42
  15. data/lib/haml/filters.rb +107 -42
  16. data/lib/haml/helpers.rb +210 -156
  17. data/lib/haml/helpers/action_view_extensions.rb +34 -39
  18. data/lib/haml/helpers/action_view_mods.rb +132 -139
  19. data/lib/haml/html.rb +77 -65
  20. data/lib/haml/precompiler.rb +404 -213
  21. data/lib/haml/shared.rb +78 -0
  22. data/lib/haml/template.rb +14 -14
  23. data/lib/haml/template/patch.rb +2 -2
  24. data/lib/haml/template/plugin.rb +2 -3
  25. data/lib/haml/util.rb +211 -6
  26. data/lib/haml/version.rb +30 -13
  27. data/lib/sass.rb +7 -856
  28. data/lib/sass/css.rb +169 -161
  29. data/lib/sass/engine.rb +344 -328
  30. data/lib/sass/environment.rb +79 -0
  31. data/lib/sass/error.rb +33 -11
  32. data/lib/sass/files.rb +139 -0
  33. data/lib/sass/plugin.rb +160 -117
  34. data/lib/sass/plugin/merb.rb +7 -6
  35. data/lib/sass/plugin/rails.rb +5 -6
  36. data/lib/sass/repl.rb +58 -0
  37. data/lib/sass/script.rb +59 -0
  38. data/lib/sass/script/bool.rb +17 -0
  39. data/lib/sass/script/color.rb +183 -0
  40. data/lib/sass/script/funcall.rb +50 -0
  41. data/lib/sass/script/functions.rb +198 -0
  42. data/lib/sass/script/lexer.rb +178 -0
  43. data/lib/sass/script/literal.rb +177 -0
  44. data/lib/sass/script/node.rb +14 -0
  45. data/lib/sass/script/number.rb +381 -0
  46. data/lib/sass/script/operation.rb +45 -0
  47. data/lib/sass/script/parser.rb +172 -0
  48. data/lib/sass/script/string.rb +12 -0
  49. data/lib/sass/script/unary_operation.rb +34 -0
  50. data/lib/sass/script/variable.rb +31 -0
  51. data/lib/sass/tree/comment_node.rb +73 -10
  52. data/lib/sass/tree/debug_node.rb +30 -0
  53. data/lib/sass/tree/directive_node.rb +42 -17
  54. data/lib/sass/tree/file_node.rb +41 -0
  55. data/lib/sass/tree/for_node.rb +48 -0
  56. data/lib/sass/tree/if_node.rb +54 -0
  57. data/lib/sass/tree/mixin_def_node.rb +29 -0
  58. data/lib/sass/tree/mixin_node.rb +48 -0
  59. data/lib/sass/tree/node.rb +214 -11
  60. data/lib/sass/tree/prop_node.rb +109 -0
  61. data/lib/sass/tree/rule_node.rb +178 -51
  62. data/lib/sass/tree/variable_node.rb +34 -0
  63. data/lib/sass/tree/while_node.rb +31 -0
  64. data/test/haml/engine_test.rb +331 -36
  65. data/test/haml/helper_test.rb +12 -1
  66. data/test/haml/results/content_for_layout.xhtml +0 -3
  67. data/test/haml/results/filters.xhtml +2 -0
  68. data/test/haml/results/list.xhtml +1 -1
  69. data/test/haml/template_test.rb +7 -2
  70. data/test/haml/templates/content_for_layout.haml +0 -2
  71. data/test/haml/templates/list.haml +1 -1
  72. data/test/haml/util_test.rb +92 -0
  73. data/test/sass/css2sass_test.rb +69 -24
  74. data/test/sass/engine_test.rb +586 -64
  75. data/test/sass/functions_test.rb +125 -0
  76. data/test/sass/more_results/more1.css +9 -0
  77. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  78. data/test/sass/more_results/more_import.css +29 -0
  79. data/test/sass/more_templates/_more_partial.sass +2 -0
  80. data/test/sass/more_templates/more1.sass +23 -0
  81. data/test/sass/more_templates/more_import.sass +11 -0
  82. data/test/sass/plugin_test.rb +81 -28
  83. data/test/sass/results/line_numbers.css +49 -0
  84. data/test/sass/results/{constants.css → script.css} +4 -4
  85. data/test/sass/results/subdir/subdir.css +2 -0
  86. data/test/sass/results/units.css +11 -0
  87. data/test/sass/script_test.rb +258 -0
  88. data/test/sass/templates/import.sass +1 -1
  89. data/test/sass/templates/importee.sass +7 -2
  90. data/test/sass/templates/line_numbers.sass +13 -0
  91. data/test/sass/templates/{constants.sass → script.sass} +11 -10
  92. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  93. data/test/sass/templates/subdir/subdir.sass +2 -2
  94. data/test/sass/templates/units.sass +11 -0
  95. data/test/test_helper.rb +14 -0
  96. metadata +77 -19
  97. data/FAQ +0 -138
  98. data/README.rdoc +0 -319
  99. data/lib/sass/constant.rb +0 -216
  100. data/lib/sass/constant/color.rb +0 -101
  101. data/lib/sass/constant/literal.rb +0 -54
  102. data/lib/sass/constant/nil.rb +0 -9
  103. data/lib/sass/constant/number.rb +0 -87
  104. data/lib/sass/constant/operation.rb +0 -30
  105. data/lib/sass/constant/string.rb +0 -22
  106. data/lib/sass/tree/attr_node.rb +0 -57
  107. data/lib/sass/tree/value_node.rb +0 -20
@@ -0,0 +1,78 @@
1
+ require 'strscan'
2
+
3
+ module Haml
4
+ # This module contains functionality that's shared between Haml and Sass.
5
+ module Shared
6
+ extend self
7
+
8
+ # Scans through a string looking for the interoplation-opening `#{`
9
+ # and, when it's found, yields the scanner to the calling code
10
+ # so it can handle it properly.
11
+ #
12
+ # The scanner will have any backslashes immediately in front of the `#{`
13
+ # as the second capture group (`scan[2]`),
14
+ # and the text prior to that as the first (`scan[1]`).
15
+ #
16
+ # @yieldparam scan [StringScanner] The scanner scanning through the string
17
+ # @return [String] The text remaining in the scanner after all `#{`s have been processed
18
+ def handle_interpolation(str)
19
+ scan = StringScanner.new(str)
20
+ yield scan while scan.scan(/(.*?)(\\*)\#\{/)
21
+ scan.rest
22
+ end
23
+
24
+ # Moves a scanner through a balanced pair of characters.
25
+ # For example:
26
+ #
27
+ # Foo (Bar (Baz bang) bop) (Bang (bop bip))
28
+ # ^ ^
29
+ # from to
30
+ #
31
+ # @param scanner [StringScanner] The string scanner to move
32
+ # @param start [Character] The character opening the balanced pair.
33
+ # A `Fixnum` in 1.8, a `String` in 1.9
34
+ # @param finish [Character] The character closing the balanced pair.
35
+ # A `Fixnum` in 1.8, a `String` in 1.9
36
+ # @param count [Fixnum] The number of opening characters matched
37
+ # before calling this method
38
+ # @return [(String, String)] The string matched within the balanced pair
39
+ # and the rest of the string.
40
+ # `["Foo (Bar (Baz bang) bop)", " (Bang (bop bip))"]` in the example above.
41
+ def balance(scanner, start, finish, count = 0)
42
+ str = ''
43
+ scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
44
+ regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
45
+ while scanner.scan(regexp)
46
+ str << scanner.matched
47
+ count += 1 if scanner.matched[-1] == start
48
+ count -= 1 if scanner.matched[-1] == finish
49
+ return [str.strip, scanner.rest] if count == 0
50
+ end
51
+ end
52
+
53
+ # Formats a string for use in error messages about indentation.
54
+ #
55
+ # @param indentation [String] The string used for indentation
56
+ # @param was [Boolean] Whether or not to add `"was"` or `"were"`
57
+ # (depending on how many characters were in `indentation`)
58
+ # @return [String] The name of the indentation (e.g. `"12 spaces"`, `"1 tab"`)
59
+ def human_indentation(indentation, was = false)
60
+ if !indentation.include?(?\t)
61
+ noun = 'space'
62
+ elsif !indentation.include?(?\s)
63
+ noun = 'tab'
64
+ else
65
+ return indentation.inspect + (was ? ' was' : '')
66
+ end
67
+
68
+ singular = indentation.length == 1
69
+ if was
70
+ was = singular ? ' was' : ' were'
71
+ else
72
+ was = ''
73
+ end
74
+
75
+ "#{indentation.length} #{noun}#{'s' unless singular}#{was}"
76
+ end
77
+ end
78
+ end
@@ -1,23 +1,23 @@
1
1
  require 'haml/engine'
2
2
 
3
3
  module Haml
4
- class Template
5
- class << self
6
- @@options = {}
4
+ # The class that keeps track of the global options for Haml within Rails.
5
+ module Template
6
+ extend self
7
7
 
8
- # Gets various options for Haml. See README.rdoc for details.
9
- def options
10
- @@options
11
- end
12
-
13
- # Sets various options for Haml. See README.rdoc for details.
14
- def options=(value)
15
- @@options = value
16
- end
17
- end
8
+ @options = {}
9
+ # The options hash for Haml when used within Rails.
10
+ # See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
11
+ #
12
+ # @return [Hash<Symbol, Object>]
13
+ attr_accessor :options
18
14
  end
19
15
  end
20
16
 
17
+ if defined?(RAILS_ENV) && RAILS_ENV == "production"
18
+ Haml::Template.options[:ugly] = true
19
+ end
20
+
21
21
  # Decide how we want to load Haml into Rails.
22
22
  # Patching was necessary for versions <= 2.0.1,
23
23
  # but we can make it a normal handler for higher versions.
@@ -35,7 +35,7 @@ if defined?(RAILS_ROOT)
35
35
  # because the new init file is sufficiently flexible
36
36
  # to not need updating.
37
37
  rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
38
- haml_init_file = Haml.scope('init.rb')
38
+ haml_init_file = Haml::Util.scope('init.rb')
39
39
  begin
40
40
  if File.exists?(rails_init_file)
41
41
  require 'fileutils'
@@ -9,7 +9,7 @@
9
9
  # The documentation can be found
10
10
  # here[http://rubyonrails.org/api/classes/ActionView/Base.html].
11
11
  module ActionView
12
- class Base # :nodoc:
12
+ class Base
13
13
  def delegate_template_exists_with_haml(template_path)
14
14
  template_exists?(template_path, :haml) && [:haml]
15
15
  end
@@ -29,7 +29,7 @@ module ActionView
29
29
 
30
30
  @@template_args[render_symbol] ||= {}
31
31
  locals_keys = @@template_args[render_symbol].keys | locals
32
- @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h }
32
+ @@template_args[render_symbol] = Haml::Util.to_hash(locals_keys.map {|k| [k, true]})
33
33
 
34
34
  options = Haml::Template.options.dup
35
35
  options[:filename] = file_name || 'compiled-template'
@@ -1,4 +1,3 @@
1
- # :stopdoc:
2
1
  # This file makes Haml work with Rails
3
2
  # using the > 2.0.1 template handler API.
4
3
 
@@ -12,7 +11,8 @@ module Haml
12
11
  # template is a template object in Rails >=2.1.0,
13
12
  # a source string previously
14
13
  if template.respond_to? :source
15
- options[:filename] = template.filename
14
+ # Template has a generic identifier in Rails >=3.0.0
15
+ options[:filename] = template.respond_to?(:identifier) ? template.identifier : template.filename
16
16
  source = template.source
17
17
  else
18
18
  source = template
@@ -69,4 +69,3 @@ if ActionView::TemplateError.instance_method(:initialize).arity == 5
69
69
  end
70
70
  end
71
71
  end
72
- # :startdoc:
@@ -1,23 +1,228 @@
1
+ require 'erb'
2
+ require 'set'
3
+ require 'enumerator'
4
+
1
5
  module Haml
6
+ # A module containing various useful functions.
2
7
  module Util
3
- class << self; include Haml::Util; end
8
+ extend self
4
9
 
10
+ # An array of ints representing the Ruby version number.
5
11
  RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
6
12
 
13
+ # Returns the path of a file relative to the Haml root directory.
14
+ #
15
+ # @param file [String] The filename relative to the Haml root
16
+ # @return [String] The filename relative to the the working directory
17
+ def scope(file)
18
+ File.join(File.dirname(__FILE__), '..', '..', file)
19
+ end
20
+
21
+ # Converts an array of `[key, value]` pairs to a hash.
22
+ # For example:
23
+ #
24
+ # to_hash([[:foo, "bar"], [:baz, "bang"]])
25
+ # #=> {:foo => "bar", :baz => "bang"}
26
+ #
27
+ # @param arr [Array<(Object, Object)>] An array of pairs
28
+ # @return [Hash] A hash
29
+ def to_hash(arr)
30
+ arr.compact.inject({}) {|h, (k, v)| h[k] = v; h}
31
+ end
32
+
33
+ # Maps the keys in a hash according to a block.
34
+ # For example:
35
+ #
36
+ # map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
37
+ # #=> {"foo" => "bar", "baz" => "bang"}
38
+ #
39
+ # @param hash [Hash] The hash to map
40
+ # @yield [key] A block in which the keys are transformed
41
+ # @yieldparam key [Object] The key that should be mapped
42
+ # @yieldreturn [Object] The new value for the key
43
+ # @return [Hash] The mapped hash
44
+ # @see #map_vals
45
+ # @see #map_hash
46
+ def map_keys(hash)
47
+ to_hash(hash.map {|k, v| [yield(k), v]})
48
+ end
49
+
50
+ # Maps the values in a hash according to a block.
51
+ # For example:
52
+ #
53
+ # map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
54
+ # #=> {:foo => :bar, :baz => :bang}
55
+ #
56
+ # @param hash [Hash] The hash to map
57
+ # @yield [value] A block in which the values are transformed
58
+ # @yieldparam value [Object] The value that should be mapped
59
+ # @yieldreturn [Object] The new value for the value
60
+ # @return [Hash] The mapped hash
61
+ # @see #map_keys
62
+ # @see #map_hash
63
+ def map_vals(hash)
64
+ to_hash(hash.map {|k, v| [k, yield(v)]})
65
+ end
66
+
67
+ # Maps the key-value pairs of a hash according to a block.
68
+ # For example:
69
+ #
70
+ # map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
71
+ # #=> {"foo" => :bar, "baz" => :bang}
72
+ #
73
+ # @param hash [Hash] The hash to map
74
+ # @yield [key, value] A block in which the key-value pairs are transformed
75
+ # @yieldparam [key] The hash key
76
+ # @yieldparam [value] The hash value
77
+ # @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
78
+ # @return [Hash] The mapped hash
79
+ # @see #map_keys
80
+ # @see #map_vals
81
+ def map_hash(hash, &block)
82
+ to_hash(hash.map(&block))
83
+ end
84
+
85
+ # Computes the powerset of the given array.
86
+ # This is the set of all subsets of the array.
87
+ # For example:
88
+ #
89
+ # powerset([1, 2, 3]) #=>
90
+ # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]
91
+ #
92
+ # @param arr [Enumerable]
93
+ # @return [Set<Set>] The subsets of `arr`
94
+ def powerset(arr)
95
+ arr.inject([Set.new].to_set) do |powerset, el|
96
+ new_powerset = Set.new
97
+ powerset.each do |subset|
98
+ new_powerset << subset
99
+ new_powerset << subset + [el]
100
+ end
101
+ new_powerset
102
+ end
103
+ end
104
+
105
+ # Concatenates all strings that are adjacent in an array,
106
+ # while leaving other elements as they are.
107
+ # For example:
108
+ #
109
+ # merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
110
+ # #=> [1, "foobar", 2, "baz"]
111
+ #
112
+ # @param enum [Enumerable]
113
+ # @return [Array] The enumerable with strings merged
114
+ def merge_adjacent_strings(enum)
115
+ e = enum.inject([]) do |a, e|
116
+ if e.is_a?(String) && a.last.is_a?(String)
117
+ a.last << e
118
+ else
119
+ a << e
120
+ end
121
+ a
122
+ end
123
+ end
124
+
125
+ # Whether or not this is running under Ruby 1.8 or lower.
126
+ #
127
+ # @return [Boolean]
7
128
  def ruby1_8?
8
129
  Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9
9
130
  end
10
131
 
132
+ # Checks to see if a class has a given method.
133
+ # For example:
134
+ #
135
+ # Haml::Util.has?(:public_instance_method, String, :gsub) #=> true
136
+ #
137
+ # Method collections like `Class#instance_methods`
138
+ # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
139
+ # so this handles checking for them in a compatible way.
140
+ #
141
+ # @param attr [#to_s] The (singular) name of the method-collection method
142
+ # (e.g. `:instance_methods`, `:private_methods`)
143
+ # @param klass [Module] The class to check the methods of which to check
144
+ # @param method [String, Symbol] The name of the method do check for
145
+ # @return [Boolean] Whether or not the given collection has the given method
11
146
  def has?(attr, klass, method)
12
147
  klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
13
148
  end
14
149
 
15
- def each_char(str, &block)
16
- if ruby1_8?
17
- str.each_byte(&block)
18
- else
19
- str.each_char(&block)
150
+ # A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
151
+ #
152
+ # @param enum [Enumerable] The enumerable to get the enumerator for
153
+ # @return [Enumerator] The with-index enumerator
154
+ def enum_with_index(enum)
155
+ ruby1_8? ? enum.enum_with_index : enum.each_with_index
156
+ end
157
+
158
+ # The context in which the ERB for \{#def\_static\_method} will be run.
159
+ class StaticConditionalContext
160
+ # @param set [#include?] The set of variables that are defined for this context.
161
+ def initialize(set)
162
+ @set = set
163
+ end
164
+
165
+ # Checks whether or not a variable is defined for this context.
166
+ #
167
+ # @param name [Symbol] The name of the variable
168
+ # @return [Boolean]
169
+ def method_missing(name, *args, &block)
170
+ super unless args.empty? && block.nil?
171
+ @set.include?(name)
20
172
  end
21
173
  end
174
+
175
+ # This is used for methods in {Haml::Buffer} that need to be very fast,
176
+ # and take a lot of boolean parameters
177
+ # that are known at compile-time.
178
+ # Instead of passing the parameters in normally,
179
+ # a separate method is defined for every possible combination of those parameters;
180
+ # these are then called using \{#static\_method\_name}.
181
+ #
182
+ # To define a static method, an ERB template for the method is provided.
183
+ # All conditionals based on the static parameters
184
+ # are done as embedded Ruby within this template.
185
+ # For example:
186
+ #
187
+ # def_static_method(Foo, :my_static_method, [:foo, :bar], :baz, :bang, <<RUBY)
188
+ # <% if baz && bang %>
189
+ # return foo + bar
190
+ # <% elsif baz || bang %>
191
+ # return foo - bar
192
+ # <% else %>
193
+ # return 17
194
+ # <% end %>
195
+ # RUBY
196
+ #
197
+ # \{#static\_method\_name} can be used to call static methods.
198
+ #
199
+ # @overload def_static_method(klass, name, args, *vars, erb)
200
+ # @param klass [Module] The class on which to define the static method
201
+ # @param name [#to_s] The (base) name of the static method
202
+ # @param args [Array<Symbol>] The names of the arguments to the defined methods
203
+ # (**not** to the ERB template)
204
+ # @param vars [Array<Symbol>] The names of the static boolean variables
205
+ # to be made available to the ERB template
206
+ # @param erb [String] The template for the method code
207
+ def def_static_method(klass, name, args, *vars)
208
+ erb = vars.pop
209
+ powerset(vars).each do |set|
210
+ context = StaticConditionalContext.new(set).instance_eval {binding}
211
+ klass.class_eval(<<METHOD)
212
+ def #{static_method_name(name, *vars.map {|v| set.include?(v)})}(#{args.join(', ')})
213
+ #{ERB.new(erb).result(context)}
214
+ end
215
+ METHOD
216
+ end
217
+ end
218
+
219
+ # Computes the name for a method defined via \{#def\_static\_method}.
220
+ #
221
+ # @param name [String] The base name of the static method
222
+ # @param vars [Array<Boolean>] The static variable assignment
223
+ # @return [String] The real name of the static method
224
+ def static_method_name(name, *vars)
225
+ "#{name}_#{vars.map {|v| !!v}.join('_')}"
226
+ end
22
227
  end
23
228
  end
@@ -1,20 +1,42 @@
1
+ require 'haml/util'
2
+
1
3
  module Haml
4
+ # Handles Haml version-reporting.
5
+ # Haml not only reports the standard three version numbers,
6
+ # but its Git revision hash as well,
7
+ # if it was installed from Git.
2
8
  module Version
9
+ include Haml::Util
10
+
3
11
  # Returns a hash representing the version of Haml.
4
- # The :major, :minor, and :teeny keys have their respective numbers.
5
- # The :string key contains a human-readable string representation of the version.
6
- # If Haml is checked out from Git,
7
- # the :rev key will have the revision hash.
12
+ # The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums.
13
+ # The `:name` key has the name of the version.
14
+ # The `:string` key contains a human-readable string representation of the version.
15
+ # The `:number` key is the major, minor, and teeny keys separated by periods.
16
+ # If Haml is checked out from Git, the `:rev` key will have the revision hash.
17
+ # For example:
18
+ #
19
+ # {
20
+ # :string => "2.1.0.9616393",
21
+ # :rev => "9616393b8924ef36639c7e82aa88a51a24d16949",
22
+ # :number => "2.1.0",
23
+ # :major => 2, :minor => 1, :teeny => 0
24
+ # }
25
+ #
26
+ # @return [Hash<Symbol, String/Fixnum>] The version hash
8
27
  def version
9
28
  return @@version if defined?(@@version)
10
29
 
11
30
  numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
31
+ name = File.read(scope('VERSION_NAME')).strip
12
32
  @@version = {
13
33
  :major => numbers[0],
14
34
  :minor => numbers[1],
15
- :teeny => numbers[2]
35
+ :teeny => numbers[2],
36
+ :name => name
16
37
  }
17
- @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
38
+ @@version[:number] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
39
+ @@version[:string] = @@version[:number].dup
18
40
 
19
41
  if File.exists?(scope('REVISION'))
20
42
  rev = File.read(scope('REVISION')).strip
@@ -31,17 +53,12 @@ module Haml
31
53
  if rev
32
54
  @@version[:rev] = rev
33
55
  unless rev[0] == ?(
34
- @@version[:string] << "."
35
- @@version[:string] << rev[0...7]
56
+ @@version[:string] << "." << rev[0...7]
36
57
  end
58
+ @@version[:string] << " (#{name})"
37
59
  end
38
60
 
39
61
  @@version
40
62
  end
41
-
42
- # Returns the path of file relative to the Haml root.
43
- def scope(file) # :nodoc:
44
- File.expand_path File.join(File.dirname(__FILE__), '..', '..', file)
45
- end
46
63
  end
47
64
  end