haml 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +38 -0
  5. data/CHANGELOG.md +43 -19
  6. data/Gemfile +18 -0
  7. data/README.md +1 -0
  8. data/Rakefile +6 -12
  9. data/TODO +24 -0
  10. data/benchmark.rb +66 -0
  11. data/haml.gemspec +39 -0
  12. data/lib/haml/.gitattributes +1 -0
  13. data/lib/haml/attribute_parser.rb +4 -0
  14. data/lib/haml/compiler.rb +2 -1
  15. data/lib/haml/helpers/safe_erubi_template.rb +0 -8
  16. data/lib/haml/options.rb +3 -0
  17. data/lib/haml/railtie.rb +11 -2
  18. data/lib/haml/temple_engine.rb +1 -0
  19. data/lib/haml/version.rb +1 -1
  20. data/test/attribute_parser_test.rb +4 -0
  21. data/test/engine_test.rb +7 -0
  22. data/test/filters_test.rb +2 -7
  23. data/test/template_test.rb +10 -0
  24. data/yard/default/.gitignore +1 -0
  25. data/yard/default/fulldoc/html/css/common.sass +15 -0
  26. data/yard/default/layout/html/footer.erb +12 -0
  27. metadata +13 -65
  28. data/test/erb/_av_partial_1.erb +0 -12
  29. data/test/erb/_av_partial_2.erb +0 -8
  30. data/test/erb/action_view.erb +0 -62
  31. data/test/erb/standard.erb +0 -55
  32. data/test/gemfiles/Gemfile.rails-4.0.x +0 -11
  33. data/test/gemfiles/Gemfile.rails-4.0.x.lock +0 -87
  34. data/test/gemfiles/Gemfile.rails-4.1.x +0 -5
  35. data/test/gemfiles/Gemfile.rails-4.2.x +0 -5
  36. data/test/gemfiles/Gemfile.rails-5.0.x +0 -4
  37. data/test/markaby/standard.mab +0 -52
  38. data/test/mocks/article.rb +0 -6
  39. data/test/results/bemit.xhtml +0 -4
  40. data/test/results/content_for_layout.xhtml +0 -12
  41. data/test/results/eval_suppressed.xhtml +0 -9
  42. data/test/results/helpers.xhtml +0 -72
  43. data/test/results/helpful.xhtml +0 -13
  44. data/test/results/just_stuff.xhtml +0 -71
  45. data/test/results/list.xhtml +0 -12
  46. data/test/results/nuke_inner_whitespace.xhtml +0 -40
  47. data/test/results/nuke_outer_whitespace.xhtml +0 -140
  48. data/test/results/original_engine.xhtml +0 -20
  49. data/test/results/partial_layout.xhtml +0 -6
  50. data/test/results/partial_layout_erb.xhtml +0 -6
  51. data/test/results/partials.xhtml +0 -22
  52. data/test/results/render_layout.xhtml +0 -3
  53. data/test/results/silent_script.xhtml +0 -74
  54. data/test/results/standard.xhtml +0 -159
  55. data/test/results/tag_parsing.xhtml +0 -23
  56. data/test/results/very_basic.xhtml +0 -5
  57. data/test/results/whitespace_handling.xhtml +0 -91
  58. data/test/template_test_helper.rb +0 -38
  59. data/test/templates/_av_partial_1.haml +0 -9
  60. data/test/templates/_av_partial_2.haml +0 -5
  61. data/test/templates/_layout.erb +0 -3
  62. data/test/templates/_layout_for_partial.haml +0 -3
  63. data/test/templates/_partial.haml +0 -8
  64. data/test/templates/_text_area.haml +0 -3
  65. data/test/templates/_text_area_helper.html.haml +0 -4
  66. data/test/templates/action_view.haml +0 -47
  67. data/test/templates/bemit.haml +0 -3
  68. data/test/templates/breakage.haml +0 -8
  69. data/test/templates/content_for_layout.haml +0 -8
  70. data/test/templates/eval_suppressed.haml +0 -11
  71. data/test/templates/helpers.haml +0 -55
  72. data/test/templates/helpful.haml +0 -11
  73. data/test/templates/just_stuff.haml +0 -86
  74. data/test/templates/list.haml +0 -12
  75. data/test/templates/nuke_inner_whitespace.haml +0 -32
  76. data/test/templates/nuke_outer_whitespace.haml +0 -144
  77. data/test/templates/original_engine.haml +0 -17
  78. data/test/templates/partial_layout.haml +0 -3
  79. data/test/templates/partial_layout_erb.erb +0 -4
  80. data/test/templates/partialize.haml +0 -1
  81. data/test/templates/partials.haml +0 -12
  82. data/test/templates/render_layout.haml +0 -2
  83. data/test/templates/silent_script.haml +0 -45
  84. data/test/templates/standard.haml +0 -43
  85. data/test/templates/standard_ugly.haml +0 -1
  86. data/test/templates/tag_parsing.haml +0 -21
  87. data/test/templates/very_basic.haml +0 -4
  88. data/test/templates/whitespace_handling.haml +0 -87
  89. data/test/templates/with_bom.haml +0 -1
  90. data/test/test_helper.rb +0 -99
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fa1e64aca629e46493a148b6159feb77763ba0d
4
- data.tar.gz: 912f3565b782829c0651604333a0d5fd823c45a1
3
+ metadata.gz: f839cdb94174ba8781070c63c81802476e784313
4
+ data.tar.gz: 95438da1cb7cd8137a2d5d6a838c126530165797
5
5
  SHA512:
6
- metadata.gz: d8e860a0fc047d158a7a1d08f349a5555ae9a0afd578327c16cca624c3c0425a323e40cc3185f8ba8fede3ed79d24babb44f634969a69707a46f27d92b925b15
7
- data.tar.gz: f3e66b26cf401ac0081721f44322a4fe39c0b0c486d6b4b0dd7e665e483be86f6f1769a0c94ed00b2646e3d76fb7be0ebe2e40c75943c0a5774e38cb3f17a4e2
6
+ metadata.gz: 8bf0fb1e2b30d0c6b0fb02bc26ce4e994a3a806fcc2a3e46f8ef4b4ef850642b3e85cbfe5660b174bddd44d04e72facceefb2c2229eb57abc5ca32bd8305790d
7
+ data.tar.gz: 23439f7250b7c914333b0702a9eade9c96a7bbf123e5df44c6099c826263bd69e3986ab5343f2c8cf7bc1a68644283a4a46685c8cbd750680ee4ec9b01b4ec62
@@ -0,0 +1,18 @@
1
+ /.yardoc
2
+ /coverage
3
+ /doc
4
+ /log
5
+ /pkg
6
+ /test/rails
7
+ /test/gemfiles/*.lock
8
+ /.haml
9
+ /site
10
+ *.rbc
11
+ .sass-cache
12
+ .rbenv-version
13
+ .rbx
14
+ .ruby-version
15
+ .rvmrc
16
+ Gemfile.lock
17
+ tmp
18
+ .bundle/
@@ -0,0 +1,3 @@
1
+ [submodule "test/haml-spec"]
2
+ path = test/haml-spec
3
+ url = git://github.com/haml/haml-spec.git
@@ -0,0 +1,38 @@
1
+ sudo: false
2
+ dist: trusty
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.1
7
+ - 2.3.4
8
+ - 2.2.7
9
+ - 2.1.10
10
+ - 2.0.0
11
+ - jruby-9.1.8.0
12
+ - rbx-3
13
+ gemfile:
14
+ - test/gemfiles/Gemfile.rails-4.0.x
15
+ - test/gemfiles/Gemfile.rails-4.1.x
16
+ - test/gemfiles/Gemfile.rails-4.2.x
17
+ - test/gemfiles/Gemfile.rails-5.0.x
18
+ - test/gemfiles/Gemfile.rails-5.1.x
19
+ matrix:
20
+ exclude:
21
+ - rvm: 2.0.0
22
+ gemfile: test/gemfiles/Gemfile.rails-5.1.x
23
+ - rvm: 2.1.10
24
+ gemfile: test/gemfiles/Gemfile.rails-5.1.x
25
+ - rvm: 2.0.0
26
+ gemfile: test/gemfiles/Gemfile.rails-5.0.x
27
+ - rvm: 2.1.10
28
+ gemfile: test/gemfiles/Gemfile.rails-5.0.x
29
+ - rvm: 2.4.1
30
+ gemfile: test/gemfiles/Gemfile.rails-4.0.x
31
+ - rvm: 2.4.1
32
+ gemfile: test/gemfiles/Gemfile.rails-4.1.x
33
+ - rvm: 2.4.1
34
+ gemfile: test/gemfiles/Gemfile.rails-4.2.x
35
+ allow_failures:
36
+ - rvm: rbx-3
37
+ fast_finish: true
38
+ script: "bundle exec rake submodules test"
@@ -1,43 +1,67 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 5.0.1
4
+
5
+ Released on May 3, 2017
6
+ ([diff](https://github.com/haml/haml/compare/v5.0.0...v5.0.1)).
7
+
8
+ * Fix parsing attributes including string interpolation. [#917](https://github.com/haml/haml/pull/917) [#921](https://github.com/haml/haml/issues/921)
9
+ * Stop distributing test files in gem package and allow installing on Windows.
10
+ * Use ActionView's Erubi/Erubis handler for erb filter only on ActionView. [#914](https://github.com/haml/haml/pull/914)
11
+
3
12
  ## 5.0.0
4
13
 
5
14
  Released on April 26, 2017
6
- ([diff](https://github.com/haml/haml/compare/4.0.7...5.0.0)).
15
+ ([diff](https://github.com/haml/haml/compare/4.0.7...v5.0.0)).
16
+
17
+ Breaking Changes
7
18
 
8
19
  * Haml now requires Ruby 2.0.0 or above.
9
20
  * Rails 3 is no longer supported, matching the official
10
21
  [Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
11
22
  (Tee Parham)
23
+ * The `haml` command's debug option (`-d`) no longer executes the Haml code, but
24
+ rather checks the generated Ruby syntax for errors.
25
+ * Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
26
+ or `Haml::Template.options` instead. (Takashi Kokubun)
27
+ * Drop dynamic quotes support and always escape `'` for `escape_html`/`escape_attrs` instead.
28
+ Also, escaped results are slightly changed and always unified to the same characters. (Takashi Kokubun)
29
+ * Don't preserve newlines in attributes. (Takashi Kokubun)
30
+ * HTML escape interpolated code in filters.
31
+ [#770](https://github.com/haml/haml/pull/770)
32
+ (Matt Wildig)
33
+
34
+ :javascript
35
+ #{JSON.generate(foo: "bar")}
36
+ Haml 4 output: {"foo":"bar"}
37
+ Haml 5 output: {"foo":"bar"}
38
+
39
+ Added
40
+
41
+ * Add a tracing option. When enabled, Haml will output a data-trace attribute on each tag showing the path
42
+ to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
43
+ * Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
44
+ * Support Rails 5.1 Erubi template handler.
45
+ * Support Sprockets 3. Thanks [Sam Davies](https://github.com/samphilipd) and [Jeremy Venezia](https://github.com/jvenezia).
46
+ * General performance and memory usage improvements. (Akira Matsuda)
47
+ * Analyze attribute values by Ripper and render static attributes beforehand. (Takashi Kokubun)
48
+ * Optimize attribute rendering about 3x faster. (Takashi Kokubun)
49
+ * Add temple gem as dependency and create `Haml::TempleEngine` class.
50
+ Some methods in `Haml::Compiler` are migrated to `Haml::TempleEngine`. (Takashi Kokubun)
51
+
52
+ Fixed
53
+
12
54
  * Fix for attribute merging. When an attribute method (or literal nested hash)
13
55
  was used in an old style attribute hash and there is also a (non-static) new
14
56
  style hash there is an error. The fix can result in different behavior in
15
57
  some circumstances. See the [commit message](https://github.com/haml/haml/tree/e475b015d3171fb4c4f140db304f7970c787d6e3)
16
58
  for detailed info. (Matt Wildig)
17
59
  * Make escape_once respect hexadecimal references. (Matt Wildig)
18
- * General performance and memory usage improvements. (Akira Matsuda)
19
60
  * Don't treat the 'data' attribute specially when merging attribute hashes. (Matt Wildig and Norman Clarke)
20
- * Add a tracing option. When enabled, Haml will output a data-trace attribute on each tag showing the path
21
- to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
22
61
  * Fix #@foo and #$foo style interpolation that was not working in html_safe mode. (Akira Matsuda)
23
- * Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
24
- * Escape Ruby script interpolated in filters. (Matt Wildig)
25
- * The `haml` command's debug option (`-d`) no longer executes the Haml code, but
26
- rather checks the generated Ruby syntax for errors.
27
- * Support Rails 5.1 Erubi template handler.
28
- * Support Sprockets 3. Thanks [Sam Davies](https://github.com/samphilipd) and [Jeremy Venezia](https://github.com/jvenezia).
29
62
  * Allow `@` as tag's class name. Thanks [Joe Bartlett](https://github.com/redoPop).
30
63
  * Raise `Haml::InvalidAttributeNameError` when attribute name includes invalid characters. (Takashi Kokubun)
31
- * Drop dynamic quotes support and always escape `'` for `escape_html`/`escape_attrs` instead.
32
- Also, escaped results are slightly changed and always unified to the same characters. (Takashi Kokubun)
33
- * Don't preserve newlines in attributes. (Takashi Kokubun)
34
- * Add temple gem as dependency and create `Haml::TempleEngine` class.
35
- Some methods in `Haml::Compiler` are migrated to `Haml::TempleEngine`. (Takashi Kokubun)
36
- * Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
37
- or `Haml::Template.options` instead. (Takashi Kokubun)
38
64
  * Don't ignore unexpected exceptions on initializing `ActionView::OutputBuffer`. (Takashi Kokubun)
39
- * Analyze attribute values by Ripper and render static attributes beforehand. (Takashi Kokubun)
40
- * Optimize attribute rendering about 3x faster. (Takashi Kokubun)
41
65
 
42
66
  ## 4.0.7
43
67
 
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem "pry"
5
+
6
+ group :docs do
7
+ gem "yard", "~> 0.8.0"
8
+ gem "kramdown"
9
+ gem "sass"
10
+ end
11
+
12
+ platform :mri do
13
+ gem "ruby-prof"
14
+ end
15
+
16
+ platform :mri_21 do
17
+ gem "simplecov"
18
+ end
data/README.md CHANGED
@@ -178,6 +178,7 @@ Haml currently supports Ruby 2.0.0 and higher, so please make sure your changes
178
178
  * [Akira Matsuda](https://github.com/amatsuda)
179
179
  * [Matt Wildig](https://github.com/mattwildig)
180
180
  * [Tee Parham](https://github.com/teeparham)
181
+ * [Takashi Kokubun](https://github.com/k0kubun)
181
182
 
182
183
  ### Alumni
183
184
 
data/Rakefile CHANGED
@@ -4,19 +4,13 @@ require "bundler/gem_tasks"
4
4
 
5
5
  task :default => :test
6
6
 
7
- # FIXME: Redefining :test task to run test/options_test.rb in isolated process since it depends on whether Rails is loaded or not.
7
+ #FIXME: Redefining :test task to run each test in isolated process.
8
8
  # Remove this task when we finished changing escape_html option to be true by default.
9
- isolated_test = Rake::TestTask.new do |t|
10
- t.libs << 'test'
11
- t.test_files = %w[test/options_test.rb]
12
- t.warning = true
13
- t.verbose = true
14
- end
15
- Rake::TestTask.new do |t|
16
- t.libs << 'test'
17
- t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] - isolated_test.file_list
18
- t.warning = true
19
- t.verbose = true
9
+ task :test do
10
+ test_files = Dir.glob('test/**/*_test.rb').reject { |f| f.start_with?('test/gemfiles/vendor/bundle') }
11
+ test_files.all? do |file|
12
+ sh(Gem.ruby, '-w', '-I/lib', '-Itest', file)
13
+ end || raise('Failures')
20
14
  end
21
15
 
22
16
  CLEAN.replace %w(pkg doc coverage .yardoc test/haml vendor)
data/TODO ADDED
@@ -0,0 +1,24 @@
1
+ # -*- mode: org -*-
2
+ #+STARTUP: nofold
3
+
4
+ * Documentation
5
+ Redo tutorial?
6
+ Using helpers
7
+ haml_concat and haml_tag in particular
8
+ Syntax highlighting?
9
+
10
+ * Code
11
+ Keep track of error offsets everywhere
12
+ Use this to show error location in messages
13
+ ** Haml
14
+ Support finer-grained HTML-escaping in filters
15
+ Speed
16
+ Make tags with dynamic attributes pre-render as much as possible
17
+ Including the attribute name where doable
18
+ :html improvements
19
+ Ignore closing tags where we can
20
+ http://code.google.com/speed/articles/optimizing-html.html
21
+ Requires Haml parsing refactor
22
+ Don't quote attributes that don't require it
23
+ http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2
24
+ http://www.w3.org/TR/html5/syntax.html#attributes
@@ -0,0 +1,66 @@
1
+ require "bundler/setup"
2
+ require "haml"
3
+ require "rbench"
4
+
5
+ times = (ARGV.first || 1000).to_i
6
+
7
+ if times == 0 # Invalid parameter
8
+ puts <<END
9
+ ruby #$0 [times=1000]
10
+ Benchmark Haml against various other templating languages.
11
+ END
12
+ exit 1
13
+ end
14
+
15
+ %w[erb erubis rails active_support action_controller
16
+ action_view action_pack haml/template rbench].each {|dep| require(dep)}
17
+
18
+ def view
19
+ base = ActionView::Base.new
20
+ base.view_paths << File.join(File.dirname(__FILE__), '/test')
21
+ base
22
+ end
23
+
24
+ def render(view, file)
25
+ view.render :file => file
26
+ end
27
+
28
+ RBench.run(times) do
29
+ column :haml, :title => "Haml"
30
+ column :erb, :title => "ERB"
31
+ column :erubis, :title => "Erubis"
32
+
33
+ template_name = 'standard'
34
+ haml_template = File.read("#{File.dirname(__FILE__)}/test/templates/#{template_name}.haml")
35
+ erb_template = File.read("#{File.dirname(__FILE__)}/test/erb/#{template_name}.erb")
36
+
37
+ report "Cached" do
38
+ obj = Object.new
39
+
40
+ Haml::Engine.new(haml_template).def_method(obj, :haml)
41
+ Erubis::Eruby.new(erb_template).def_method(obj, :erubis)
42
+ obj.instance_eval("def erb; #{ERB.new(erb_template, nil, '-').src}; end")
43
+
44
+ haml { obj.haml }
45
+ erb { obj.erb }
46
+ erubis { obj.erubis }
47
+ end
48
+
49
+ report "ActionView" do
50
+ # To cache the template
51
+ render view, 'templates/standard'
52
+ render view, 'erb/standard'
53
+
54
+ haml { render view, 'templates/standard' }
55
+ erb { render view, 'erb/standard' }
56
+ end
57
+
58
+ report "ActionView with deep partials" do
59
+ # To cache the template
60
+ render view, 'templates/action_view'
61
+ render view, 'erb/action_view'
62
+
63
+ haml { render view, 'templates/action_view' }
64
+ erb { render view, 'erb/action_view' }
65
+ end
66
+ end
@@ -0,0 +1,39 @@
1
+ ($LOAD_PATH << File.expand_path("../lib", __FILE__)).uniq!
2
+ require "haml/version"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'haml'
6
+ spec.summary = "An elegant, structured (X)HTML/XML templating engine."
7
+ spec.version = Haml::VERSION
8
+ spec.authors = ['Natalie Weizenbaum', 'Hampton Catlin', 'Norman Clarke', 'Akira Matsuda']
9
+ spec.email = ['haml@googlegroups.com', 'norman@njclarke.com']
10
+
11
+ readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
12
+ spec.executables = ['haml']
13
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
+ f.match(%r{\Atest/})
15
+ end
16
+ spec.homepage = 'http://haml.info/'
17
+ spec.has_rdoc = false
18
+ spec.test_files = Dir["test/**/*_test.rb"]
19
+ spec.license = "MIT"
20
+
21
+ spec.required_ruby_version = '>= 2.0.0'
22
+
23
+ spec.add_dependency 'temple', '>= 0.8.0'
24
+ spec.add_dependency 'tilt'
25
+
26
+ spec.add_development_dependency 'rails', '>= 4.0.0'
27
+ spec.add_development_dependency 'rbench'
28
+ spec.add_development_dependency 'minitest', '>= 4.0'
29
+ spec.add_development_dependency 'nokogiri'
30
+
31
+ spec.description = <<-END
32
+ Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
33
+ designed to express the structure of documents in a non-repetitive, elegant, and
34
+ easy way by using indentation rather than closing tags and allowing Ruby to be
35
+ embedded with ease. It was originally envisioned as a plugin for Ruby on Rails,
36
+ but it can function as a stand-alone templating engine.
37
+ END
38
+
39
+ end
@@ -0,0 +1 @@
1
+ version.rb merge=ours
@@ -131,6 +131,10 @@ module Haml
131
131
  open_tokens[:paren] += 1
132
132
  when :on_rparen
133
133
  open_tokens[:paren] -= 1
134
+ when :on_embexpr_beg
135
+ open_tokens[:embexpr] += 1
136
+ when :on_embexpr_end
137
+ open_tokens[:embexpr] -= 1
134
138
  when *IGNORED_TYPES
135
139
  next if attr_tokens.empty?
136
140
  end
@@ -14,6 +14,7 @@ module Haml
14
14
  @to_merge = []
15
15
  @temple = [:multi]
16
16
  @node = nil
17
+ @filters = Filters.defined.merge(options[:filters])
17
18
  @attribute_compiler = AttributeCompiler.new(@options)
18
19
  end
19
20
 
@@ -168,7 +169,7 @@ module Haml
168
169
  end
169
170
 
170
171
  def compile_filter
171
- unless filter = Filters.defined[@node.value[:name]]
172
+ unless filter = @filters[@node.value[:name]]
172
173
  name = @node.value[:name]
173
174
  if ["maruku", "textile"].include?(name)
174
175
  raise Error.new(Error.message(:install_haml_contrib, name), @node.line - 1)
@@ -15,13 +15,5 @@ module Haml
15
15
  @options.merge! engine_class: Haml::ErubiTemplateHandler
16
16
  super
17
17
  end
18
-
19
- def precompiled_preamble(locals)
20
- [super, "@output_buffer = ActionView::OutputBuffer.new;"].join("\n")
21
- end
22
-
23
- def precompiled_postamble(locals)
24
- [super, '@output_buffer.to_s'].join("\n")
25
- end
26
18
  end
27
19
  end
@@ -164,6 +164,9 @@ module Haml
164
164
  # the path will be the full path.
165
165
  attr_accessor :trace
166
166
 
167
+ # Key is filter name in String and value is Class to use. Defaults to {}.
168
+ attr_accessor :filters
169
+
167
170
  def initialize(values = {}, &block)
168
171
  defaults.each {|k, v| instance_variable_set :"@#{k}", v}
169
172
  values.each {|k, v| send("#{k}=", v) if defaults.has_key?(k) && !v.nil?}
@@ -9,6 +9,14 @@ if (activesupport_spec = Gem.loaded_specs['activesupport'])
9
9
  end
10
10
 
11
11
  module Haml
12
+ module Filters
13
+ module RailsErb
14
+ extend Plain
15
+ extend TiltFilter
16
+ extend PrecompiledTiltFilter
17
+ end
18
+ end
19
+
12
20
  class Railtie < ::Rails::Railtie
13
21
  initializer :haml do |app|
14
22
  ActiveSupport.on_load(:action_view) do
@@ -20,11 +28,12 @@ module Haml
20
28
 
21
29
  if defined? Erubi
22
30
  require "haml/helpers/safe_erubi_template"
23
- Haml::Filters::Erb.template_class = Haml::SafeErubiTemplate
31
+ Haml::Filters::RailsErb.template_class = Haml::SafeErubiTemplate
24
32
  else
25
33
  require "haml/helpers/safe_erubis_template"
26
- Haml::Filters::Erb.template_class = Haml::SafeErubisTemplate
34
+ Haml::Filters::RailsErb.template_class = Haml::SafeErubisTemplate
27
35
  end
36
+ Haml::Template.options[:filters] = { 'erb' => Haml::Filters::RailsErb }
28
37
  end
29
38
  end
30
39
  end
@@ -25,6 +25,7 @@ module Haml
25
25
  parser_class: ::Haml::Parser,
26
26
  compiler_class: ::Haml::Compiler,
27
27
  trace: false,
28
+ filters: {},
28
29
  )
29
30
 
30
31
  use :Parser, -> { options[:parser_class] }