haml 4.0.1 → 4.0.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.

@@ -1,5 +1,16 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 4.0.2
4
+
5
+ Released April 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.1...4.0.2)).
6
+
7
+ * Explicitly require Erubis to work around bug in older versions of Tilt.
8
+ * Fix :erb filter printing duplicate content in Rails views.
9
+ (thanks [Jori Hardman](https://github.com/jorihardman))
10
+ * Replace range with slice to reduce objects created by `capture_haml`.
11
+ (thanks [Tieg Zaharia](https://github.com/tiegz))
12
+ * Correct/improve some documentation.
13
+
3
14
  ## 4.0.1
4
15
 
5
16
  Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0.1)).
@@ -130,8 +130,8 @@ encoding.
130
130
 
131
131
  By default, the HTML generated by Haml has the same encoding as the Haml
132
132
  template. However, if `Encoding.default_internal` is set, Haml will attempt to
133
- use that instead. In addition, the [`:encoding` option](#encoding-option) can be
134
- used to specify an output encoding manually.
133
+ use that instead. In addition, the {Haml::Options#encoding `:encoding` option}
134
+ can be used to specify an output encoding manually.
135
135
 
136
136
  Note that, like Ruby, Haml does not support templates encoded in UTF-16 or
137
137
  UTF-32, since these encodings are not compatible with ASCII. It is possible to
@@ -186,7 +186,6 @@ is compiled to:
186
186
 
187
187
  ## HTML Elements
188
188
 
189
-
190
189
  ### Element Name: `%`
191
190
 
192
191
  The percent character is placed at the beginning of a line. It's followed
@@ -406,9 +405,9 @@ will render as:
406
405
  <a data-author-id='123' href='/posts'>Posts By Author</a>
407
406
 
408
407
  Notice that the underscore in `author_id` was replaced by a hyphen. If you wish
409
- to suppress this behavior, you can set Haml's [`:hyphenate_data_attrs`
410
- option](#hyphenate_data_attrs-option) to `false`, and the output will be
411
- rendered as:
408
+ to suppress this behavior, you can set Haml's
409
+ {Haml::Options#hyphenate_data_attrs `:hyphenate_data_attrs` option} to `false`,
410
+ and the output will be rendered as:
412
411
 
413
412
  <a data-author_id='123' href='/posts'>Posts By Author</a>
414
413
 
@@ -492,31 +491,32 @@ and is compiled to:
492
491
  </div>
493
492
  </div>
494
493
 
495
- ### Self-Closing Tags: `/`
494
+ ### Empty (void) Tags: `/`
496
495
 
497
496
  The forward slash character, when placed at the end of a tag definition, causes
498
- the tag to be self-closed. For example:
497
+ Haml to treat it as being an empty (or void) element. Depending on the format,
498
+ the tag will be rendered either without a closing tag (`:html4` or `:html5`), or
499
+ as a self-closing tag (`:xhtml`). For example:
499
500
 
500
501
  %br/
501
502
  %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
502
503
 
503
504
  is compiled to:
504
505
 
505
- <br />
506
- <meta http-equiv='Content-Type' content='text/html' />
506
+ <br>
507
+ <meta content='text/html' http-equiv='Content-Type'>
507
508
 
508
- Some tags are automatically closed, as long as they have no content. `meta`,
509
- `img`, `link`, `script`, `br`, and `hr` tags are closed by default. This list
510
- can be customized by setting the [`:autoclose`](#autoclose-option) option. For
511
- example:
509
+ when the format is `:html4` or `:html5`, and to
512
510
 
513
- %br
514
- %meta{'http-equiv' => 'Content-Type', :content => 'text/html'}
511
+ <br />
512
+ <meta content='text/html' http-equiv='Content-Type' />
515
513
 
516
- is also compiled to:
514
+ when the format is `:xhtml`.
517
515
 
518
- <br />
519
- <meta http-equiv='Content-Type' content='text/html' />
516
+ Some tags are automatically treated as being empty, as long as they have no
517
+ content in the Haml source. `meta`, `img`, `link`, `script`, `br`, and `hr` tags
518
+ are treated as empty by default. This list can be customized by setting the
519
+ {Haml::Options#autoclose `:autoclose`} option.
520
520
 
521
521
  ### Whitespace Removal: `>` and `<`
522
522
 
@@ -621,7 +621,6 @@ is compiled to:
621
621
  Hello!
622
622
  </div>
623
623
 
624
-
625
624
  ## Doctype: `!!!`
626
625
 
627
626
  When describing HTML documents with Haml, you can have a document type or XML
@@ -651,7 +650,7 @@ is compiled to:
651
650
  </html>
652
651
 
653
652
  You can also specify the specific doctype after the `!!!` When the
654
- [`:format`](#format-option) is set to `:xhtml`. The following doctypes are
653
+ {Haml::Options#format `:format`} is set to `:xhtml`. The following doctypes are
655
654
  supported:
656
655
 
657
656
  `!!!`
@@ -686,7 +685,7 @@ supported:
686
685
  : XHTML+RDFa 1.0<br/>
687
686
  `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">`
688
687
 
689
- When the [`:format`](#format-option) option is set to `:html4`, the following
688
+ When the {Haml::Options#format `:format`} option is set to `:html4`, the following
690
689
  doctypes are supported:
691
690
 
692
691
  `!!!`
@@ -701,7 +700,7 @@ doctypes are supported:
701
700
  : HTML 4.01 Frameset<br/>
702
701
  `<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`
703
702
 
704
- When the [`:format`](#format-option) option is set to `:html5`,
703
+ When the {Haml::Options#format `:format`} option is set to `:html5`,
705
704
  `!!!` is always `<!DOCTYPE html>`.
706
705
 
707
706
  If you're not using the UTF-8 character set for your document, you can specify
@@ -821,7 +820,7 @@ is compiled to:
821
820
  yo
822
821
  </p>
823
822
 
824
- If the [`:escape_html`](#escape_html-option) option is set, `=` will sanitize
823
+ If the {Haml::Options#escape_html `:escape_html`} option is set, `=` will sanitize
825
824
  any HTML-sensitive characters generated by the script. For example:
826
825
 
827
826
  = '<script>alert("I\'m evil!");</script>'
@@ -1099,8 +1098,8 @@ control when CDATA tags are added.
1099
1098
  {#erb-filter}
1100
1099
  ### `:erb`
1101
1100
  Parses the filtered text with ERb, like an RHTML template. Not available if the
1102
- [`:suppress_eval`](#suppress_eval-option) option is set to true. Embedded Ruby
1103
- code is evaluated in the same context as the Haml template. This filter is
1101
+ {Haml::Options#suppress_eval `:suppress_eval`} option is set to true. Embedded
1102
+ Ruby code is evaluated in the same context as the Haml template. This filter is
1104
1103
  implemented using Tilt.
1105
1104
 
1106
1105
  {#escaped-filter}
@@ -1119,7 +1118,6 @@ option} to control when CDATA tags are added.
1119
1118
  Parses the filtered text with [Less](http://lesscss.org/) to produce CSS output.
1120
1119
  This filter is implemented using Tilt.
1121
1120
 
1122
-
1123
1121
  {#markdown-filter}
1124
1122
  ### `:markdown`
1125
1123
  Parses the filtered text with
@@ -1151,10 +1149,11 @@ HTML escape code for newlines, to preserve nice-looking output. See also
1151
1149
 
1152
1150
  {#ruby-filter}
1153
1151
  ### `:ruby`
1154
- Parses the filtered text with the normal Ruby interpreter. All output sent to
1155
- `$stdout`, like with `puts`, is output into the Haml document. Not available if
1156
- the [`:suppress_eval`](#suppress_eval-option) option is set to true. The Ruby
1157
- code is evaluated in the same context as the Haml template.
1152
+ Parses the filtered text with the normal Ruby interpreter. Creates an `IO`
1153
+ object named `haml_io`, anything written to it is output into the Haml document.
1154
+ Not available if the {Haml::Options#suppress_eval `:suppress_eval`} option is
1155
+ set to true. The Ruby code is evaluated in the same context as the Haml
1156
+ template.
1158
1157
 
1159
1158
  {#sass-filter}
1160
1159
  ### `:sass`
@@ -1231,14 +1230,15 @@ Sometimes you don't want Haml to indent all your text.
1231
1230
  For example, tags like `pre` and `textarea` are whitespace-sensitive;
1232
1231
  indenting the text makes them render wrong.
1233
1232
 
1234
- Haml deals with this by "preserving" newlines before they're put into the document --
1235
- converting them to the HTML whitespace escape code, `&#x000A;`.
1236
- Then Haml won't try to re-format the indentation.
1233
+ Haml deals with this by "preserving" newlines before they're put into the
1234
+ document -- converting them to the HTML whitespace escape code, `&#x000A;`. Then
1235
+ Haml won't try to re-format the indentation.
1237
1236
 
1238
- Literal `textarea` and `pre` tags automatically preserve content given through `=`.
1239
- Dynamically-generated `textarea`s and `pre`s can't be preserved automatically,
1240
- and so should be passed through {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde),
1241
- which has the same effect.
1237
+ Literal `textarea` and `pre` tags automatically preserve content given through
1238
+ `=`. Dynamically-generated `textarea`s and `pre`s can't be preserved
1239
+ automatically, and so should be passed through
1240
+ {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde), which has the
1241
+ same effect.
1242
1242
 
1243
1243
  Blocks of literal text can be preserved using the [`:preserve` filter](#preserve-filter).
1244
1244
 
data/Rakefile CHANGED
@@ -20,7 +20,11 @@ end
20
20
 
21
21
  Rake::TestTask.new do |t|
22
22
  t.libs << 'lib' << 'test'
23
- t.test_files = Dir["test/**/*_test.rb"]
23
+ # haml-spec tests are explicitly added after other tests so they don't
24
+ # interfere with the Haml loading process which can cause test failures
25
+ files = Dir["test/*_test.rb"]
26
+ files.concat(Dir['test/haml-spec/*_test.rb'])
27
+ t.test_files = files
24
28
  t.verbose = true
25
29
  end
26
30
 
@@ -94,7 +98,7 @@ def gemfiles
94
98
  @gemfiles ||= begin
95
99
  Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
96
100
  reject {|f| f =~ /\.lock$/}.
97
- reject {|f| RUBY_VERSION < '1.9.3' && f =~ /master/}
101
+ reject {|f| RUBY_VERSION < '1.9.3' && f =~ /Gemfile.rails-(\d+).\d+.x/ && $1.to_i > 3}
98
102
  end
99
103
  end
100
104
 
@@ -267,8 +267,6 @@ RUBY
267
267
  # a newline after textarea helpers.
268
268
  #
269
269
  # @param input [String] The text to process
270
- # @param tabs [String] The tabs provided by the Haml::Buffer
271
- # @param options [Hash] The options hash provided by the Haml::Buffer
272
270
  # @since Haml 4.0.1
273
271
  # @private
274
272
  def fix_textareas!(input)
@@ -385,6 +385,8 @@ RUBY
385
385
  module Erb
386
386
  class << self
387
387
  def precompiled(text)
388
+ #workaround for https://github.com/rtomayko/tilt/pull/183
389
+ require 'erubis' if (defined?(::Erubis) && !defined?(::Erubis::Eruby))
388
390
  super.sub(/^#coding:.*?\n/, '')
389
391
  end
390
392
  end
@@ -381,7 +381,7 @@ MESSAGE
381
381
  end
382
382
 
383
383
  captured.map do |line|
384
- line[min_tabs..-1]
384
+ line.slice(min_tabs, line.length)
385
385
  end.join
386
386
  end
387
387
  ensure
@@ -10,7 +10,7 @@ module Haml
10
10
  end
11
11
 
12
12
  def precompiled_preamble(locals)
13
- [super, "@output_buffer = output_buffer ||= nil || ActionView::OutputBuffer.new;"]
13
+ [super, "@output_buffer = ActionView::OutputBuffer.new;"]
14
14
  end
15
15
 
16
16
  def precompiled_postamble(locals)
@@ -1,3 +1,3 @@
1
1
  module Haml
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 4.0.1
5
+ version: 4.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Weizenbaum
@@ -11,88 +11,88 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-03-21 00:00:00.000000000 Z
14
+ date: 2013-04-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  version_requirements: !ruby/object:Gem::Requirement
18
+ none: false
18
19
  requirements:
19
20
  - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: '0'
22
- none: false
23
- type: :runtime
24
23
  name: tilt
24
+ type: :runtime
25
25
  prerelease: false
26
26
  requirement: !ruby/object:Gem::Requirement
27
+ none: false
27
28
  requirements:
28
29
  - - ! '>='
29
30
  - !ruby/object:Gem::Version
30
31
  version: '0'
31
- none: false
32
32
  - !ruby/object:Gem::Dependency
33
33
  version_requirements: !ruby/object:Gem::Requirement
34
+ none: false
34
35
  requirements:
35
36
  - - ! '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: 3.0.0
38
- none: false
39
- type: :development
40
39
  name: rails
40
+ type: :development
41
41
  prerelease: false
42
42
  requirement: !ruby/object:Gem::Requirement
43
+ none: false
43
44
  requirements:
44
45
  - - ! '>='
45
46
  - !ruby/object:Gem::Version
46
47
  version: 3.0.0
47
- none: false
48
48
  - !ruby/object:Gem::Dependency
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- none: false
55
- type: :development
56
55
  name: rbench
56
+ type: :development
57
57
  prerelease: false
58
58
  requirement: !ruby/object:Gem::Requirement
59
+ none: false
59
60
  requirements:
60
61
  - - ! '>='
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
- none: false
64
64
  - !ruby/object:Gem::Dependency
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
+ none: false
66
67
  requirements:
67
68
  - - ! '>='
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
- none: false
71
- type: :development
72
71
  name: minitest
72
+ type: :development
73
73
  prerelease: false
74
74
  requirement: !ruby/object:Gem::Requirement
75
+ none: false
75
76
  requirements:
76
77
  - - ! '>='
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
79
- none: false
80
80
  - !ruby/object:Gem::Dependency
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
+ none: false
82
83
  requirements:
83
84
  - - ! '>='
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
- none: false
87
- type: :development
88
87
  name: nokogiri
88
+ type: :development
89
89
  prerelease: false
90
90
  requirement: !ruby/object:Gem::Requirement
91
+ none: false
91
92
  requirements:
92
93
  - - ! '>='
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
- none: false
96
96
  description: ! 'Haml (HTML Abstraction Markup Language) is a layer on top of HTML
97
97
  or XML that''s
98
98
 
@@ -244,17 +244,17 @@ rdoc_options: []
244
244
  require_paths:
245
245
  - lib
246
246
  required_ruby_version: !ruby/object:Gem::Requirement
247
+ none: false
247
248
  requirements:
248
249
  - - ! '>='
249
250
  - !ruby/object:Gem::Version
250
251
  version: '0'
251
- none: false
252
252
  required_rubygems_version: !ruby/object:Gem::Requirement
253
+ none: false
253
254
  requirements:
254
255
  - - ! '>='
255
256
  - !ruby/object:Gem::Version
256
257
  version: '0'
257
- none: false
258
258
  requirements: []
259
259
  rubyforge_project:
260
260
  rubygems_version: 1.8.23