haml 3.2.0.beta.1 → 3.2.0.beta.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/CHANGELOG.md CHANGED
@@ -13,7 +13,8 @@
13
13
 
14
14
  * Haml's internals have been refactored to move the parser, compiler and options
15
15
  handling into independent classes, rather than including them all in the
16
- Engine module.
16
+ Engine module. You can also specify your own custom Haml parser or compiler
17
+ class in Haml::Options in order to extend or modify Haml reasonably easily.
17
18
 
18
19
  * The :sass filter now wraps its output in a script tag, as do the new :less and
19
20
  :scss filters. The :coffee filter wraps its output in a script tag.
data/REFERENCE.md CHANGED
@@ -1,4 +1,4 @@
1
- # Haml (XHTML Abstraction Markup Language)
1
+ # Haml (HTML Abstraction Markup Language)
2
2
 
3
3
  Haml is a markup language that's used to cleanly and simply describe the HTML of
4
4
  any web document, without the use of inline code. Haml functions as a
data/lib/haml/engine.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'forwardable'
2
2
 
3
+ require 'haml/parser'
4
+ require 'haml/compiler'
3
5
  require 'haml/options'
4
6
  require 'haml/helpers'
5
7
  require 'haml/buffer'
6
- require 'haml/parser'
7
- require 'haml/compiler'
8
8
  require 'haml/filters'
9
9
  require 'haml/error'
10
10
 
@@ -60,8 +60,8 @@ module Haml
60
60
 
61
61
  initialize_encoding options[:encoding]
62
62
 
63
- @parser = Parser.new(@template, @options)
64
- @compiler = Compiler.new(@options)
63
+ @parser = @options.parser_class.new(@template, @options)
64
+ @compiler = @options.compiler_class.new(@options)
65
65
 
66
66
  @compiler.compile(@parser.parse)
67
67
  end
data/lib/haml/exec.rb CHANGED
@@ -237,6 +237,11 @@ END
237
237
  @options[:for_engine][:attr_wrapper] = '"'
238
238
  end
239
239
 
240
+ opts.on('--cdata',
241
+ 'Always add CDATA sections to javascript and css blocks.') do
242
+ @options[:for_engine][:cdata] = true
243
+ end
244
+
240
245
  opts.on('-r', '--require FILE', "Same as 'ruby -r'.") do |file|
241
246
  @options[:requires] << file
242
247
  end
data/lib/haml/options.rb CHANGED
@@ -19,7 +19,9 @@ module Haml
19
19
  :remove_whitespace => false,
20
20
  :suppress_eval => false,
21
21
  :ugly => false,
22
- :cdata => false
22
+ :cdata => false,
23
+ :parser_class => ::Haml::Parser,
24
+ :compiler_class => ::Haml::Compiler
23
25
  }
24
26
 
25
27
  @valid_formats = [:html4, :html5, :xhtml]
@@ -160,6 +162,12 @@ module Haml
160
162
  # xhtml.
161
163
  attr_accessor :cdata
162
164
 
165
+ # The parser class to use. Defaults to Haml::Parser.
166
+ attr_accessor :parser_class
167
+
168
+ # The compiler class to use. Defaults to Haml::Compiler.
169
+ attr_accessor :compiler_class
170
+
163
171
  def initialize(values = {}, &block)
164
172
  defaults.each {|k, v| instance_variable_set :"@#{k}", v}
165
173
  values.reject {|k, v| !defaults.has_key?(k) || v.nil?}.each {|k, v| send("#{k}=", v)}
data/lib/haml/parser.rb CHANGED
@@ -444,7 +444,7 @@ module Haml
444
444
  end
445
445
 
446
446
  def close_silent_script(node)
447
- @script_level_stack.pop if node.value[:keyword] == "if"
447
+ @script_level_stack.pop if ["if", "case", "unless"].include? node.value[:keyword]
448
448
 
449
449
  # Post-process case statements to normalize the nesting of "when" clauses
450
450
  return unless node.value[:keyword] == "case"
@@ -8,7 +8,7 @@ module Haml
8
8
 
9
9
  @options = {}
10
10
  # The options hash for Haml when used within Rails.
11
- # See {file:REFERENCE.md#haml_options the Haml options documentation}.
11
+ # See {file:REFERENCE.md#options the Haml options documentation}.
12
12
  #
13
13
  # @return [{Symbol => Object}]
14
14
  attr_accessor :options
@@ -8,7 +8,7 @@ module Haml
8
8
  # the ERB handler does.
9
9
 
10
10
  # In Rails 3.1+, we don't need to include Compilable.
11
- if ::Rails.version < "3.1"
11
+ if ActionPack::VERSION::MAJOR < 3 || (ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 1)
12
12
  include ActionView::Template::Handlers::Compilable
13
13
  end
14
14
 
data/lib/haml/util.rb CHANGED
@@ -301,8 +301,6 @@ METHOD
301
301
  # Formats a string for use in error messages about indentation.
302
302
  #
303
303
  # @param indentation [String] The string used for indentation
304
- # @param was [Boolean] Whether or not to add `"was"` or `"were"`
305
- # (depending on how many characters were in `indentation`)
306
304
  # @return [String] The name of the indentation (e.g. `"12 spaces"`, `"1 tab"`)
307
305
  def human_indentation(indentation)
308
306
  if !indentation.include?(?\t)
data/lib/haml/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Haml
2
- VERSION = "3.2.0.beta.1"
2
+ VERSION = "3.2.0.beta.2"
3
3
  end
data/test/engine_test.rb CHANGED
@@ -1930,7 +1930,7 @@ HAML
1930
1930
  - foo.each do | item |
1931
1931
  = item
1932
1932
  HAML
1933
- rescue ::SyntaxError => e
1933
+ rescue ::SyntaxError
1934
1934
  flunk("Should not have raised syntax error")
1935
1935
  end
1936
1936
  end
data/test/parser_test.rb CHANGED
@@ -48,6 +48,25 @@ module Haml
48
48
  end
49
49
  end
50
50
 
51
+ test "else after if containing case is accepted" do
52
+ # see issue 572
53
+ begin
54
+ parse "- if true\n - case @foo\n - when 1\n bar\n- else\n bar"
55
+ assert true
56
+ rescue SyntaxError
57
+ flunk 'else clause after if containing case should be accepted'
58
+ end
59
+ end
60
+
61
+ test "else after if containing unless is accepted" do
62
+ begin
63
+ parse "- if true\n - unless @foo\n bar\n- else\n bar"
64
+ assert true
65
+ rescue SyntaxError
66
+ flunk 'else clause after if containing unless should be accepted'
67
+ end
68
+ end
69
+
51
70
  private
52
71
 
53
72
  def parse(haml, options = nil)
@@ -23,6 +23,11 @@
23
23
  Odd!
24
24
  - else
25
25
  Even!
26
+ - unless true
27
+ Testing else indent
28
+ - case 1
29
+ - when 2
30
+ Also testing else indent
26
31
  - else
27
32
  = "This can't happen!"
28
33
  - 13 |
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.beta.1
4
+ version: 3.2.0.beta.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-27 00:00:00.000000000 Z
14
+ date: 2012-08-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: tilt
@@ -209,7 +209,7 @@ post_install_message: ! '
209
209
 
210
210
  * Support for Rails 2 dropped
211
211
 
212
- * Sass filter now always outputs <script> tags
212
+ * Sass filter now always outputs <style> tags
213
213
 
214
214
  * Data attributes are now hyphenated, not underscored
215
215
 
@@ -234,9 +234,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
234
  - - ! '>='
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
- segments:
238
- - 0
239
- hash: -1734032859910060370
240
237
  required_rubygems_version: !ruby/object:Gem::Requirement
241
238
  none: false
242
239
  requirements: