haml 4.1.0.alpha.2 → 4.1.0.beta.1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e558b5f2cf40a4dc76dd5a6d4a6fd7410087cea
4
- data.tar.gz: de7642c1dd34404f48def114391e5070ea0d78fa
3
+ metadata.gz: e6db8c2e57e4132457faca789a5700112ee9a8e5
4
+ data.tar.gz: c4f15045d582be5eeb7daecb3781c6102920beb9
5
5
  SHA512:
6
- metadata.gz: 1713fd685aee4177c59ea3f3353c65a875c2cc3cbf8a840c20c96d2bd2308dad11f28c04d73fde0bfcedfd7e3e50e90a2b20ae17ee0fe8769285971cb5f651bf
7
- data.tar.gz: f6a1e655ac0fdaeeb9ae8e215fad6b79673da33f9c404ac192dca1f8dbc8bb81becb33250554c3e2b29907054efb6e28b22349a1153126ba09b40fd1ff734de5
6
+ metadata.gz: 3fabebdd299e3cea1516c42d40b6d63c96dbcf073434d11794403933b7b6fb233e0460908317256abbb07b7281da3b3582ac1b26676725cdc6462cbd31234d00
7
+ data.tar.gz: 3eff7188b9d214cf4face1dc8078c598c45369cb70a4caad27d74fc53d29ab7de5748ff7997a24b6dc807c4ee926c72bf6373885bc517ba525b541fe8bdf5ee9
@@ -3,6 +3,9 @@
3
3
  ## 4.1.0 (Unreleased)
4
4
 
5
5
  * Haml now requires Ruby 1.9.2 or above.
6
+ * Rails 3.0 and 3.1 are no longer supported, matching the official
7
+ [Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
8
+ (Tee Parham)
6
9
  * Fix for attribute merging. When an attribute method (or literal nested hash)
7
10
  was used in an old style attribute hash and there is also a (non-static) new
8
11
  style hash there is an error. The fix can result in different behavior in
@@ -12,6 +15,16 @@
12
15
  * General performance and memory usage improvements. (Akira Matsuda)
13
16
  * Don't treat the 'data' attribute specially when merging attribute hashes. (Matt Wildig and Norman Clarke)
14
17
 
18
+ ## 4.0.5
19
+
20
+ Released on Jan 7, 2014 ([diff](https://github.com/haml/haml/compare/4.0.4...4.0.5)).
21
+
22
+ * Fix haml_concat appending unescaped HTML after a call to haml_tag.
23
+ * Fix for bug whereby when HAML :ugly option is "true",
24
+ ActionView::Helpers::CaptureHelper::capture returns the whole view buffer
25
+ when passed a block that returns nothing (thanks [Mircea
26
+ Moise](https://github.com/mmircea16)).
27
+
15
28
  ## 4.0.4
16
29
 
17
30
  Released on November 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.3...4.0.4)).
@@ -1349,3 +1362,4 @@ has been moved to [YARD](http://yard.soen.ca).
1349
1362
  YARD is an excellent documentation system,
1350
1363
  and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
1351
1364
  which is also excellent.
1365
+ >>>>>>> External Changes
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/haml/haml.png?branch=master)](http://travis-ci.org/haml/haml)
4
4
  [![Code Climate](https://codeclimate.com/github/haml/haml.png)](https://codeclimate.com/github/haml/haml)
5
+ [![Coverage Status](https://coveralls.io/repos/haml/haml/badge.png)](https://coveralls.io/r/haml/haml)
5
6
 
6
7
  Haml is a templating engine for HTML. It's designed to make it both easier and
7
8
  more pleasant to write HTML documents, by eliminating redundancy, reflecting the
@@ -30,6 +31,13 @@ documentation](http://haml.info/docs/yardoc/).
30
31
 
31
32
  To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
32
33
 
34
+ gem 'haml'
35
+
36
+ Haml 4.1 requires an actively maintained version of Rails (version 3.2 or later).
37
+ If you are using Rails 3.0 or 3.1, you should use Haml version 4.0.x:
38
+
39
+ gem 'haml', '~> 4.0.4'
40
+
33
41
  If you'd like to replace Rails's Erb-based generators with Haml, add
34
42
  [haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well.
35
43
 
@@ -137,6 +145,7 @@ both 1.9 and 2.0.
137
145
  * [Norman Clarke](http://github.com/norman)
138
146
  * [Matt Wildig](http://github.com/mattwildig)
139
147
  * [Akira Matsuda](https://github.com/amatsuda)
148
+ * [Tee Parham](https://github.com/teeparham)
140
149
 
141
150
  ### Alumni
142
151
 
@@ -4,6 +4,10 @@ module Haml
4
4
  # It's called from within the precompiled code,
5
5
  # and helps reduce the amount of processing done within `instance_eval`ed code.
6
6
  class Buffer
7
+ ID_KEY = 'id'.freeze
8
+ CLASS_KEY = 'class'.freeze
9
+ DATA_KEY = 'data'.freeze
10
+
7
11
  include Haml::Helpers
8
12
  include Haml::Util
9
13
 
@@ -115,8 +119,8 @@ module Haml
115
119
  text.sub!(tabs, '') if dont_tab_up
116
120
  end
117
121
 
118
- @buffer << text
119
122
  @real_tabs += tab_change
123
+ @buffer << text
120
124
  end
121
125
 
122
126
  # Modifies the indentation of the document.
@@ -231,19 +235,19 @@ RUBY
231
235
  # @param from [{String => #to_s}] The attribute hash to merge from
232
236
  # @return [{String => String}] `to`, after being merged
233
237
  def self.merge_attrs(to, from)
234
- from['id'] = Compiler.filter_and_join(from['id'], '_') if from['id']
235
- if to['id'] && from['id']
236
- to['id'] << "_#{from.delete('id')}"
237
- elsif to['id'] || from['id']
238
- from['id'] ||= to['id']
238
+ from[ID_KEY] = Compiler.filter_and_join(from[ID_KEY], '_') if from[ID_KEY]
239
+ if to[ID_KEY] && from[ID_KEY]
240
+ to[ID_KEY] << "_#{from.delete(ID_KEY)}"
241
+ elsif to[ID_KEY] || from[ID_KEY]
242
+ from[ID_KEY] ||= to[ID_KEY]
239
243
  end
240
244
 
241
- from['class'] = Compiler.filter_and_join(from['class'], ' ') if from['class']
242
- if to['class'] && from['class']
245
+ from[CLASS_KEY] = Compiler.filter_and_join(from[CLASS_KEY], ' ') if from[CLASS_KEY]
246
+ if to[CLASS_KEY] && from[CLASS_KEY]
243
247
  # Make sure we don't duplicate class names
244
- from['class'] = (from['class'].to_s.split(' ') | to['class'].split(' ')).sort.join(' ')
245
- elsif to['class'] || from['class']
246
- from['class'] ||= to['class']
248
+ from[CLASS_KEY] = (from[CLASS_KEY].to_s.split(' ') | to[CLASS_KEY].split(' ')).sort.join(' ')
249
+ elsif to[CLASS_KEY] || from[CLASS_KEY]
250
+ from[CLASS_KEY] ||= to[CLASS_KEY]
247
251
  end
248
252
 
249
253
  from.keys.each do |key|
@@ -327,7 +331,7 @@ RUBY
327
331
  id = "#{ prefix }_#{ id }"
328
332
  end
329
333
 
330
- {'id' => id, 'class' => class_name}
334
+ {ID_KEY => id, CLASS_KEY => class_name}
331
335
  end
332
336
 
333
337
  # Changes a word from camel case to underscores.
@@ -194,19 +194,18 @@ MESSAGE
194
194
  # @yieldparam item An element of `enum`
195
195
  def list_of(enum, opts={}, &block)
196
196
  opts_attributes = opts.empty? ? "" : " ".<<(opts.map{|k,v| "#{k}='#{v}'" }.join(" "))
197
- to_return = enum.collect do |i|
197
+ enum.collect do |i|
198
198
  result = capture_haml(i, &block)
199
199
 
200
- if result.count("\n") > 1
200
+ result = if result.count("\n") > 1
201
201
  result.gsub!("\n", "\n ")
202
- result = "\n #{result.strip}\n"
202
+ "\n #{result.strip}\n"
203
203
  else
204
- result = result.strip
204
+ result.strip
205
205
  end
206
206
 
207
207
  %Q!<li#{opts_attributes}>#{result}</li>!
208
- end
209
- to_return.join("\n")
208
+ end.join("\n")
210
209
  end
211
210
 
212
211
  # Returns a hash containing default assignments for the `xmlns`, `lang`, and `xml:lang`
@@ -372,25 +371,16 @@ MESSAGE
372
371
  position = haml_buffer.buffer.length
373
372
 
374
373
  haml_buffer.capture_position = position
375
- block.call(*args)
374
+ value = block.call(*args)
376
375
 
377
376
  captured = haml_buffer.buffer.slice!(position..-1)
378
- return captured if haml_buffer.options[:ugly]
379
- # Note that the "reject" is needed for rbx 1.2.4, which includes empty
380
- # strings in the returned array when splitting by /^/.
381
- captured = captured.split(/^/)
382
- captured.delete('')
383
-
384
- min_tabs = nil
385
- captured.each do |line|
386
- tabs = line.index(/[^ ]/) || line.length
387
- min_tabs ||= tabs
388
- min_tabs = min_tabs > tabs ? tabs : min_tabs
377
+
378
+ if captured == '' and value != haml_buffer.buffer
379
+ captured = (value.is_a?(String) ? value : nil)
389
380
  end
390
381
 
391
- captured.map do |line|
392
- line.slice(min_tabs, line.length)
393
- end.join
382
+ return nil if captured.nil?
383
+ return (haml_buffer.options[:ugly] ? captured : prettify(captured))
394
384
  end
395
385
  ensure
396
386
  haml_buffer.capture_position = nil
@@ -400,10 +390,10 @@ MESSAGE
400
390
  #
401
391
  # @param text [#to_s] The text to output
402
392
  def haml_concat(text = "")
403
- unless haml_buffer.options[:ugly] || haml_indent == 0
404
- haml_buffer.buffer << %[#{haml_indent}#{text.to_s.gsub("\n", "\n#{haml_indent}")}\n]
405
- else
393
+ if haml_buffer.options[:ugly] || haml_indent == 0
406
394
  haml_buffer.buffer << "#{text}\n"
395
+ else
396
+ haml_buffer.buffer << %[#{haml_indent}#{text.to_s.gsub("\n", "\n#{haml_indent}")}\n]
407
397
  end
408
398
  ErrorReturn.new("haml_concat")
409
399
  end
@@ -669,6 +659,22 @@ MESSAGE
669
659
  _erbout = _erbout = _hamlout.buffer
670
660
  proc { |*args| proc.call(*args) }
671
661
  end
662
+
663
+ def prettify(text)
664
+ text = text.split(/^/)
665
+ text.delete('')
666
+
667
+ min_tabs = nil
668
+ text.each do |line|
669
+ tabs = line.index(/[^ ]/) || line.length
670
+ min_tabs ||= tabs
671
+ min_tabs = min_tabs > tabs ? tabs : min_tabs
672
+ end
673
+
674
+ text.map do |line|
675
+ line.slice(min_tabs, line.length)
676
+ end.join
677
+ end
672
678
  end
673
679
  end
674
680
 
@@ -45,8 +45,8 @@ module Haml
45
45
  # @yield A block in which all input to `#haml_concat` is treated as raw.
46
46
  # @see Haml::Util#rails_xss_safe?
47
47
  def with_raw_haml_concat
48
+ old = instance_variable_defined?('@_haml_concat_raw') ? @_haml_concat_raw : false
48
49
  @_haml_concat_raw = true
49
- old = @_haml_concat_raw
50
50
  yield
51
51
  ensure
52
52
  @_haml_concat_raw = old
@@ -41,20 +41,8 @@ module ActionView
41
41
  if Haml::Helpers.block_is_haml?(block)
42
42
  #double assignment is to avoid warnings
43
43
  _hamlout = _hamlout = eval('_hamlout', block.binding) # Necessary since capture_haml checks _hamlout
44
- value = nil
45
- buffer = capture_haml(*args) { value = yield(*args) }
46
- str =
47
- if !buffer.empty?
48
- buffer
49
- elsif value.is_a?(String)
50
- value
51
- else
52
- nil
53
- end
54
- # NonCattingString is present in Rails less than 3.1.0. When support
55
- # for 3.0 is dropped, this can be removed.
56
- return ActionView::NonConcattingString.new(str) if str && defined?(ActionView::NonConcattingString)
57
- return str
44
+
45
+ capture_haml(*args, &block)
58
46
  else
59
47
  capture_without_haml(*args, &block)
60
48
  end
@@ -151,4 +139,4 @@ module ActionView
151
139
  alias_method :form_for, :form_for_with_haml
152
140
  end
153
141
  end
154
- end
142
+ end
@@ -6,7 +6,9 @@ module Haml
6
6
 
7
7
  @defaults = {
8
8
  :attr_wrapper => "'",
9
- :autoclose => %w(meta img link br hr input area param col base),
9
+ :autoclose => %w(area base basefont br col command embed frame
10
+ hr img input isindex keygen link menuitem meta
11
+ param source track wbr),
10
12
  :encoding => "UTF-8",
11
13
  :escape_attrs => true,
12
14
  :escape_html => false,
@@ -85,6 +85,9 @@ module Haml
85
85
  # The Regex that matches a literal string or symbol value
86
86
  LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?!\\|\#{|\#@|\#\$|\2).|\\.)*\2/
87
87
 
88
+ ID_KEY = 'id'.freeze
89
+ CLASS_KEY = 'class'.freeze
90
+
88
91
  def initialize(template, options)
89
92
  @options = options
90
93
  @flat = false
@@ -165,8 +168,8 @@ module Haml
165
168
  return @template_tabs + 1 if flat? && line.whitespace =~ /^#{@flat_spaces}/
166
169
 
167
170
  message = Error.message(:inconsistent_indentation,
168
- Haml::Util.human_indentation(line.whitespace),
169
- Haml::Util.human_indentation(@indentation)
171
+ human_indentation(line.whitespace),
172
+ human_indentation(@indentation)
170
173
  )
171
174
  raise SyntaxError.new(message, line.index)
172
175
  end
@@ -509,13 +512,13 @@ module Haml
509
512
  list.scan(/([#.])([-:_a-zA-Z0-9]+)/) do |type, property|
510
513
  case type
511
514
  when '.'
512
- if attributes['class']
513
- attributes['class'] += " "
515
+ if attributes[CLASS_KEY]
516
+ attributes[CLASS_KEY] += " "
514
517
  else
515
- attributes['class'] = ""
518
+ attributes[CLASS_KEY] = ""
516
519
  end
517
- attributes['class'] += property
518
- when '#'; attributes['id'] = property
520
+ attributes[CLASS_KEY] += property
521
+ when '#'; attributes[ID_KEY] = property
519
522
  end
520
523
  end
521
524
  attributes
@@ -1,4 +1,11 @@
1
1
  if defined?(ActiveSupport)
2
+ # check for a compatible Rails version when Haml is loaded
3
+ if (activesupport_spec = Gem.loaded_specs['activesupport'])
4
+ if activesupport_spec.version.to_s < '3.2'
5
+ raise Exception.new("\n\n** Haml now requires Rails 3.2 and later. Use Haml version 4.0.4\n\n")
6
+ end
7
+ end
8
+
2
9
  require 'haml/template/options'
3
10
  ActiveSupport.on_load(:before_initialize) do
4
11
  ActiveSupport.on_load(:action_view) do
@@ -19,4 +26,4 @@ module Haml
19
26
  end
20
27
 
21
28
  require "haml/helpers/safe_erubis_template"
22
- Haml::Filters::Erb.template_class = Haml::SafeErubisTemplate
29
+ Haml::Filters::Erb.template_class = Haml::SafeErubisTemplate
@@ -1,17 +1,7 @@
1
1
  module Haml
2
2
 
3
3
  # This module makes Haml work with Rails using the template handler API.
4
- class Plugin < ActionView::Template::Handlers::ERB.superclass
5
-
6
- # Rails 3.1+, template handlers don't inherit from anything. In <= 3.0, they
7
- # do. To avoid messy logic figuring this out, we just inherit from whatever
8
- # the ERB handler does.
9
-
10
- # In Rails 3.1+, we don't need to include Compilable.
11
- if (ActionPack::VERSION::MAJOR == 3) && (ActionPack::VERSION::MINOR < 1)
12
- include ActionView::Template::Handlers::Compilable
13
- end
14
-
4
+ class Plugin
15
5
  def handles_encoding?; true; end
16
6
 
17
7
  def compile(template)
@@ -25,7 +15,6 @@ module Haml
25
15
  Haml::Engine.new(template.source, options).compiler.precompiled_with_ambles([])
26
16
  end
27
17
 
28
- # In Rails 3.1+, #call takes the place of #compile
29
18
  def self.call(template)
30
19
  new.compile(template)
31
20
  end
@@ -38,4 +27,4 @@ module Haml
38
27
  end
39
28
  end
40
29
 
41
- ActionView::Template.register_template_handler(:haml, Haml::Plugin)
30
+ ActionView::Template.register_template_handler(:haml, Haml::Plugin)
@@ -0,0 +1,85 @@
1
+ require 'haml'
2
+ require 'temple'
3
+
4
+ module Haml
5
+
6
+ module Temple
7
+
8
+ module Expressions
9
+ def on_plain
10
+ [:static, "\n" + value[:text]]
11
+ end
12
+
13
+ def on_root
14
+ [:multi]
15
+ end
16
+
17
+ def on_doctype
18
+ [:html, :doctype, value[:version] || 5]
19
+ end
20
+
21
+ def on_tag
22
+ exp = [:html, :tag, value[:name], [:html, :attrs]]
23
+ if value[:value] && value[:value] != ""
24
+ if value[:parse]
25
+ exp.push << [:dynamic, value[:value]]
26
+ else
27
+ exp.push << [:static, value[:value]]
28
+ end
29
+ end
30
+
31
+ if attribs = value[:attributes]
32
+ attribs.each do |key, value|
33
+ exp.last << [:html, :attr, key, [:static, value]]
34
+ end
35
+ end
36
+
37
+ exp
38
+ end
39
+ end
40
+
41
+ class Parser
42
+ def initialize(*args)
43
+ @options = Options.new
44
+ end
45
+
46
+ def call(haml)
47
+ parser = ::Haml::Parser.new(haml, @options)
48
+ tree = parser.parse.tap {|x| p x; puts '-' * 10}
49
+ compile(tree).tap {|x| p x; puts '-' * 10}
50
+ end
51
+
52
+ private
53
+
54
+ def compile(node)
55
+ exp = node.to_temple
56
+ return exp if node.children.empty?
57
+ if node.children.length == 1
58
+ exp.push compile(node.children[0])
59
+ else
60
+ exp.push [:multi, *node.children.map {|c| compile(c)}]
61
+ end
62
+ exp
63
+ end
64
+ end
65
+
66
+ class Engine < ::Temple::Engine
67
+ use ::Haml::Temple::Parser
68
+ html :Pretty
69
+ filter :ControlFlow
70
+ generator :ArrayBuffer
71
+ end
72
+ end
73
+
74
+ class Parser::ParseNode
75
+ include ::Haml::Temple::Expressions
76
+
77
+ def to_temple
78
+ begin
79
+ send "on_#{type}"
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ Haml::Temple::Template = Temple::Templates::Tilt(Haml::Temple::Engine, :register_as => :haml)
@@ -56,19 +56,6 @@ module Haml
56
56
  $stderr = the_real_stderr
57
57
  end
58
58
 
59
- # Returns an ActionView::Template* class.
60
- # In pre-3.0 versions of Rails, most of these classes
61
- # were of the form `ActionView::TemplateFoo`,
62
- # while afterwards they were of the form `ActionView::Template::Foo`.
63
- #
64
- # @param name [#to_s] The name of the class to get.
65
- # For example, `:Error` will return `ActionView::TemplateError`
66
- # or `ActionView::Template::Error`.
67
- def av_template_class(name)
68
- return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
69
- return ActionView::Template.const_get(name.to_s)
70
- end
71
-
72
59
  ## Rails XSS Safety
73
60
 
74
61
  # Whether or not ActionView's XSS protection is available and enabled,
@@ -1,3 +1,3 @@
1
1
  module Haml
2
- VERSION = "4.1.0.alpha.2"
2
+ VERSION = "4.1.0.beta.1"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rails', '>= 3.2.0', '< 3.3.0'
3
+ gem 'rails', '~> 3.2.0'
4
4
  gemspec :path => "../.."
5
-
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'bundler', '~> 1.3.0'
4
- gem 'rails', '~> 4.0.0.rc1'
3
+ gem 'coveralls', require: false
4
+ gem 'rails', '~> 4.0.0'
5
5
  gemspec :path => '../..'
@@ -14,6 +14,16 @@ module Haml::Helpers
14
14
  def something_that_uses_haml_concat
15
15
  haml_concat('foo').to_s
16
16
  end
17
+
18
+ def render_something_with_haml_concat
19
+ haml_concat "<p>"
20
+ end
21
+
22
+ def render_something_with_haml_tag_and_concat
23
+ haml_tag 'p' do
24
+ haml_concat '<foo>'
25
+ end
26
+ end
17
27
  end
18
28
 
19
29
  class HelperTest < MiniTest::Unit::TestCase
@@ -34,12 +44,6 @@ class HelperTest < MiniTest::Unit::TestCase
34
44
  @base = ActionView::Base.new
35
45
  @base.controller = ActionController::Base.new
36
46
  @base.view_paths << File.expand_path("../templates", __FILE__)
37
-
38
- if defined?(ActionController::Response)
39
- # This is needed for >=3.0.0
40
- @base.controller.response = ActionController::Response.new
41
- end
42
-
43
47
  @base.instance_variable_set('@post', Post.new("Foo bar\nbaz", nil, PostErrors.new))
44
48
  end
45
49
 
@@ -48,6 +52,15 @@ class HelperTest < MiniTest::Unit::TestCase
48
52
  super
49
53
  end
50
54
 
55
+ def test_rendering_with_escapes
56
+ output = render(<<-HAML, :action_view)
57
+ - render_something_with_haml_concat
58
+ - render_something_with_haml_tag_and_concat
59
+ - render_something_with_haml_concat
60
+ HAML
61
+ assert_equal("&lt;p&gt;\n<p>\n <foo>\n</p>\n&lt;p&gt;\n", output)
62
+ end
63
+
51
64
  def test_flatten
52
65
  assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))
53
66
 
@@ -101,7 +114,7 @@ HAML
101
114
 
102
115
  begin
103
116
  ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>")
104
- rescue NoMethodError, Haml::Util.av_template_class(:Error)
117
+ rescue NoMethodError, ActionView::Template::Error
105
118
  proper_behavior = true
106
119
  end
107
120
  assert(proper_behavior)
@@ -91,7 +91,7 @@ class TemplateTest < MiniTest::Unit::TestCase
91
91
  assert_equal(pair.first, pair.last, message)
92
92
  end
93
93
  end
94
- rescue Haml::Util.av_template_class(:Error) => e
94
+ rescue ActionView::Template::Error => e
95
95
  if e.message =~ /Can't run [\w:]+ filter; required (one of|file) ((?:'\w+'(?: or )?)+)(, but none were found| not found)/
96
96
  puts "\nCouldn't require #{$2}; skipping a test."
97
97
  else
@@ -111,6 +111,29 @@ class TemplateTest < MiniTest::Unit::TestCase
111
111
  end
112
112
  end
113
113
 
114
+ def test_render_method_returning_null_with_ugly
115
+ @base.instance_eval do
116
+ def empty
117
+ nil
118
+ end
119
+ def render_something(&block)
120
+ capture(self, &block)
121
+ end
122
+ end
123
+
124
+ content_to_render = "%h1 This is part of the broken view.\n= render_something do |thing|\n = thing.empty do\n = 'test'"
125
+ result = render(content_to_render, :ugly => true)
126
+ expected_result = "<h1>This is part of the broken view.</h1>\n"
127
+ assert_equal(expected_result, result)
128
+ end
129
+
130
+ def test_simple_rendering_with_ugly
131
+ content_to_render = "%p test\n= capture { 'foo' }"
132
+ result = render(content_to_render, :ugly => true)
133
+ expected_result = "<p>test</p>\nfoo\n"
134
+ assert_equal(expected_result, result)
135
+ end
136
+
114
137
  def test_templates_should_render_correctly_with_render_proc
115
138
  assert_renders_correctly("standard") do |name|
116
139
  engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :format => :xhtml)
@@ -1,18 +1,29 @@
1
+ begin
2
+ if RUBY_VERSION >= '2.0.0'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+ end
6
+ rescue LoadError
7
+ # ignore error for other test Gemfiles
8
+ end
9
+
1
10
  if ENV["COVERAGE"]
2
11
  require "simplecov"
3
12
  SimpleCov.start
4
13
  end
5
14
 
6
- require 'rubygems'
7
- gem "minitest"
8
15
  require 'bundler/setup'
9
16
  require 'minitest/autorun'
10
17
  require 'action_pack'
11
18
  require 'action_controller'
12
19
  require 'action_view'
13
20
  require 'nokogiri'
14
-
15
21
  require 'rails'
22
+
23
+ if defined?(I18n.enforce_available_locales)
24
+ I18n.enforce_available_locales = true
25
+ end
26
+
16
27
  class TestApp < Rails::Application
17
28
  config.root = ""
18
29
  end
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: 4.1.0.alpha.2
4
+ version: 4.1.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -10,78 +10,78 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-05 00:00:00.000000000 Z
13
+ date: 2014-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- type: :runtime
17
16
  name: tilt
18
- prerelease: false
19
17
  requirement: !ruby/object:Gem::Requirement
20
18
  requirements:
21
19
  - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
- type: :development
31
30
  name: rails
32
- prerelease: false
33
31
  requirement: !ruby/object:Gem::Requirement
34
32
  requirements:
35
33
  - - ">="
36
34
  - !ruby/object:Gem::Version
37
- version: 3.0.0
35
+ version: 3.2.0
36
+ type: :development
37
+ prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 3.0.0
42
+ version: 3.2.0
43
43
  - !ruby/object:Gem::Dependency
44
- type: :development
45
44
  name: rbench
46
- prerelease: false
47
45
  requirement: !ruby/object:Gem::Requirement
48
46
  requirements:
49
47
  - - ">="
50
48
  - !ruby/object:Gem::Version
51
49
  version: '0'
50
+ type: :development
51
+ prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
- type: :development
59
58
  name: minitest
60
- prerelease: false
61
59
  requirement: !ruby/object:Gem::Requirement
62
60
  requirements:
63
- - - ">="
61
+ - - "~>"
64
62
  - !ruby/object:Gem::Version
65
- version: '0'
63
+ version: '4.0'
64
+ type: :development
65
+ prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '4.0'
71
71
  - !ruby/object:Gem::Dependency
72
- type: :development
73
72
  name: nokogiri
74
- prerelease: false
75
73
  requirement: !ruby/object:Gem::Requirement
76
74
  requirements:
77
75
  - - "~>"
78
76
  - !ruby/object:Gem::Version
79
- version: 1.5.10
77
+ version: 1.6.0
78
+ type: :development
79
+ prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 1.5.10
84
+ version: 1.6.0
85
85
  description: |
86
86
  Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
87
87
  designed to express the structure of documents in a non-repetitive, elegant, and
@@ -96,6 +96,14 @@ executables:
96
96
  extensions: []
97
97
  extra_rdoc_files: []
98
98
  files:
99
+ - ".yardopts"
100
+ - CHANGELOG.md
101
+ - FAQ.md
102
+ - MIT-LICENSE
103
+ - README.md
104
+ - REFERENCE.md
105
+ - Rakefile
106
+ - bin/haml
99
107
  - lib/haml.rb
100
108
  - lib/haml/buffer.rb
101
109
  - lib/haml/compiler.rb
@@ -104,39 +112,34 @@ files:
104
112
  - lib/haml/exec.rb
105
113
  - lib/haml/filters.rb
106
114
  - lib/haml/helpers.rb
107
- - lib/haml/options.rb
108
- - lib/haml/parser.rb
109
- - lib/haml/railtie.rb
110
- - lib/haml/sass_rails_filter.rb
111
- - lib/haml/template.rb
112
- - lib/haml/util.rb
113
- - lib/haml/version.rb
114
115
  - lib/haml/helpers/action_view_extensions.rb
115
116
  - lib/haml/helpers/action_view_mods.rb
116
117
  - lib/haml/helpers/action_view_xss_mods.rb
117
118
  - lib/haml/helpers/safe_erubis_template.rb
118
119
  - lib/haml/helpers/xss_mods.rb
120
+ - lib/haml/options.rb
121
+ - lib/haml/parser.rb
122
+ - lib/haml/railtie.rb
123
+ - lib/haml/sass_rails_filter.rb
124
+ - lib/haml/template.rb
119
125
  - lib/haml/template/options.rb
120
126
  - lib/haml/template/plugin.rb
121
- - bin/haml
127
+ - lib/haml/temple.rb
128
+ - lib/haml/util.rb
129
+ - lib/haml/version.rb
122
130
  - test/engine_test.rb
123
- - test/filters_test.rb
124
- - test/helper_test.rb
125
- - test/parser_test.rb
126
- - test/template_test.rb
127
- - test/test_helper.rb
128
- - test/util_test.rb
129
131
  - test/erb/_av_partial_1.erb
130
132
  - test/erb/_av_partial_2.erb
131
133
  - test/erb/action_view.erb
132
134
  - test/erb/standard.erb
133
- - test/gemfiles/Gemfile.rails-3.0.x
134
- - test/gemfiles/Gemfile.rails-3.1.x
135
+ - test/filters_test.rb
135
136
  - test/gemfiles/Gemfile.rails-3.2.x
136
137
  - test/gemfiles/Gemfile.rails-4.0.x
137
138
  - test/gemfiles/Gemfile.rails-4.0.x.lock
139
+ - test/helper_test.rb
138
140
  - test/markaby/standard.mab
139
141
  - test/mocks/article.rb
142
+ - test/parser_test.rb
140
143
  - test/results/content_for_layout.xhtml
141
144
  - test/results/eval_suppressed.xhtml
142
145
  - test/results/helpers.xhtml
@@ -155,6 +158,7 @@ files:
155
158
  - test/results/tag_parsing.xhtml
156
159
  - test/results/very_basic.xhtml
157
160
  - test/results/whitespace_handling.xhtml
161
+ - test/template_test.rb
158
162
  - test/templates/_av_partial_1.haml
159
163
  - test/templates/_av_partial_1_ugly.haml
160
164
  - test/templates/_av_partial_2.haml
@@ -188,13 +192,8 @@ files:
188
192
  - test/templates/very_basic.haml
189
193
  - test/templates/whitespace_handling.haml
190
194
  - test/templates/with_bom.haml
191
- - Rakefile
192
- - ".yardopts"
193
- - CHANGELOG.md
194
- - FAQ.md
195
- - MIT-LICENSE
196
- - README.md
197
- - REFERENCE.md
195
+ - test/test_helper.rb
196
+ - test/util_test.rb
198
197
  homepage: http://haml.info/
199
198
  licenses:
200
199
  - MIT
@@ -230,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
229
  version: 1.3.1
231
230
  requirements: []
232
231
  rubyforge_project:
233
- rubygems_version: 2.1.5
232
+ rubygems_version: 2.2.0
234
233
  signing_key:
235
234
  specification_version: 4
236
235
  summary: An elegant, structured (X)HTML/XML templating engine.
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '>= 3.0.0', '< 3.1.0'
4
- gemspec :path => "../.."
5
-
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '>= 3.1.0', '< 3.2.0'
4
- gemspec :path => "../.."
5
-
6
-