haml 4.0.0 → 5.0.0
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.
- checksums.yaml +7 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +117 -5
- data/FAQ.md +7 -17
- data/MIT-LICENSE +1 -1
- data/README.md +85 -42
- data/REFERENCE.md +181 -86
- data/Rakefile +47 -51
- data/lib/haml/attribute_builder.rb +163 -0
- data/lib/haml/attribute_compiler.rb +215 -0
- data/lib/haml/attribute_parser.rb +144 -0
- data/lib/haml/buffer.rb +38 -128
- data/lib/haml/compiler.rb +88 -295
- data/lib/haml/engine.rb +25 -41
- data/lib/haml/error.rb +3 -0
- data/lib/haml/escapable.rb +49 -0
- data/lib/haml/exec.rb +33 -19
- data/lib/haml/filters.rb +20 -24
- data/lib/haml/generator.rb +41 -0
- data/lib/haml/helpers/action_view_extensions.rb +3 -2
- data/lib/haml/helpers/action_view_mods.rb +44 -66
- data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
- data/lib/haml/helpers/safe_erubi_template.rb +27 -0
- data/lib/haml/helpers/safe_erubis_template.rb +16 -4
- data/lib/haml/helpers/xss_mods.rb +18 -12
- data/lib/haml/helpers.rb +122 -58
- data/lib/haml/options.rb +39 -46
- data/lib/haml/parser.rb +278 -217
- data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
- data/lib/haml/railtie.rb +21 -11
- data/lib/haml/sass_rails_filter.rb +17 -4
- data/lib/haml/template/options.rb +12 -2
- data/lib/haml/template.rb +12 -6
- data/lib/haml/temple_engine.rb +120 -0
- data/lib/haml/temple_line_counter.rb +29 -0
- data/lib/haml/util.rb +80 -199
- data/lib/haml/version.rb +2 -1
- data/lib/haml.rb +2 -1
- data/test/attribute_parser_test.rb +101 -0
- data/test/engine_test.rb +306 -176
- data/test/filters_test.rb +32 -19
- data/test/gemfiles/Gemfile.rails-4.0.x +11 -0
- data/test/gemfiles/Gemfile.rails-4.0.x.lock +87 -0
- data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
- data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
- data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
- data/test/helper_test.rb +282 -96
- data/test/options_test.rb +22 -0
- data/test/parser_test.rb +71 -4
- data/test/results/bemit.xhtml +4 -0
- data/test/results/eval_suppressed.xhtml +4 -4
- data/test/results/helpers.xhtml +43 -41
- data/test/results/helpful.xhtml +6 -3
- data/test/results/just_stuff.xhtml +21 -20
- data/test/results/list.xhtml +9 -9
- data/test/results/nuke_inner_whitespace.xhtml +22 -22
- data/test/results/nuke_outer_whitespace.xhtml +84 -92
- data/test/results/original_engine.xhtml +17 -17
- data/test/results/partial_layout.xhtml +4 -3
- data/test/results/partial_layout_erb.xhtml +4 -3
- data/test/results/partials.xhtml +11 -10
- data/test/results/silent_script.xhtml +63 -63
- data/test/results/standard.xhtml +156 -159
- data/test/results/tag_parsing.xhtml +19 -19
- data/test/results/very_basic.xhtml +2 -2
- data/test/results/whitespace_handling.xhtml +56 -50
- data/test/template_test.rb +44 -53
- data/test/template_test_helper.rb +38 -0
- data/test/templates/_text_area_helper.html.haml +4 -0
- data/test/templates/bemit.haml +3 -0
- data/test/templates/just_stuff.haml +1 -0
- data/test/templates/partial_layout_erb.erb +1 -1
- data/test/templates/standard_ugly.haml +1 -0
- data/test/templates/with_bom.haml +1 -0
- data/test/temple_line_counter_test.rb +40 -0
- data/test/test_helper.rb +26 -12
- data/test/util_test.rb +6 -47
- metadata +88 -106
- data/lib/haml/helpers/rails_323_textarea_fix.rb +0 -24
- data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
- data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
- data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
- data/test/gemfiles/Gemfile.rails-master +0 -4
- data/test/templates/_av_partial_1_ugly.haml +0 -9
- data/test/templates/_av_partial_2_ugly.haml +0 -5
- data/test/templates/action_view_ugly.haml +0 -47
- data/test/templates/standard_ugly.haml +0 -43
    
        data/test/filters_test.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            class FiltersTest <  | 
| 3 | 
            +
            class FiltersTest < Haml::TestCase
         | 
| 4 4 | 
             
              test "should be registered as filters when including Haml::Filters::Base" do
         | 
| 5 5 | 
             
                begin
         | 
| 6 6 | 
             
                  refute Haml::Filters.defined.has_key? "bar"
         | 
| @@ -26,8 +26,11 @@ class FiltersTest < MiniTest::Unit::TestCase | |
| 26 26 | 
             
              test "should raise error when a Tilt filters dependencies are unavailable for extension" do
         | 
| 27 27 | 
             
                begin
         | 
| 28 28 | 
             
                  assert_raises Haml::Error do
         | 
| 29 | 
            -
                     | 
| 30 | 
            -
                     | 
| 29 | 
            +
                    # ignore warnings from Tilt
         | 
| 30 | 
            +
                    silence_warnings do
         | 
| 31 | 
            +
                      Haml::Filters.register_tilt_filter "Textile"
         | 
| 32 | 
            +
                      Haml::Filters.defined["textile"].template_class
         | 
| 33 | 
            +
                    end
         | 
| 31 34 | 
             
                  end
         | 
| 32 35 | 
             
                ensure
         | 
| 33 36 | 
             
                  Haml::Filters.remove_filter "Textile"
         | 
| @@ -64,7 +67,7 @@ class FiltersTest < MiniTest::Unit::TestCase | |
| 64 67 | 
             
              end
         | 
| 65 68 |  | 
| 66 69 | 
             
              test "should respect escaped newlines and interpolation" do
         | 
| 67 | 
            -
                html = "\\n\n"
         | 
| 70 | 
            +
                html = "\\n\n\n"
         | 
| 68 71 | 
             
                haml = ":plain\n  \\n\#{""}"
         | 
| 69 72 | 
             
                assert_equal(html, render(haml))
         | 
| 70 73 | 
             
              end
         | 
| @@ -73,16 +76,21 @@ class FiltersTest < MiniTest::Unit::TestCase | |
| 73 76 | 
             
                assert_equal("\n", render(':plain'))
         | 
| 74 77 | 
             
              end
         | 
| 75 78 |  | 
| 76 | 
            -
              test " | 
| 79 | 
            +
              test ":plain with content" do
         | 
| 77 80 | 
             
                expectation = "foo\n"
         | 
| 78 | 
            -
                assert_equal(expectation, render(":plain\n  foo" | 
| 81 | 
            +
                assert_equal(expectation, render(":plain\n  foo"))
         | 
| 79 82 | 
             
              end
         | 
| 80 83 |  | 
| 81 84 | 
             
              test "should pass options to Tilt filters that precompile" do
         | 
| 82 | 
            -
                 | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 85 | 
            +
                begin
         | 
| 86 | 
            +
                  orig_erb_opts = Haml::Filters::Erb.options
         | 
| 87 | 
            +
                  haml  = ":erb\n  <%= 'foo' %>"
         | 
| 88 | 
            +
                  refute_match('test_var', Haml::Engine.new(haml).compiler.precompiled)
         | 
| 89 | 
            +
                  Haml::Filters::Erb.options = {:outvar => 'test_var'}
         | 
| 90 | 
            +
                  assert_match('test_var', Haml::Engine.new(haml).compiler.precompiled)
         | 
| 91 | 
            +
                ensure
         | 
| 92 | 
            +
                  Haml::Filters::Erb.options = orig_erb_opts
         | 
| 93 | 
            +
                end
         | 
| 86 94 | 
             
              end
         | 
| 87 95 |  | 
| 88 96 | 
             
              test "should pass options to Tilt filters that don't precompile" do
         | 
| @@ -109,9 +117,14 @@ class FiltersTest < MiniTest::Unit::TestCase | |
| 109 117 | 
             
                end
         | 
| 110 118 | 
             
              end
         | 
| 111 119 |  | 
| 120 | 
            +
              test "interpolated code should be escaped if escape_html is set" do
         | 
| 121 | 
            +
                assert_equal "<script>evil</script>\n\n",
         | 
| 122 | 
            +
                             render(":plain\n  \#{'<script>evil</script>'}", :escape_html => true)
         | 
| 123 | 
            +
              end
         | 
| 124 | 
            +
             | 
| 112 125 | 
             
            end
         | 
| 113 126 |  | 
| 114 | 
            -
            class ErbFilterTest <  | 
| 127 | 
            +
            class ErbFilterTest < Haml::TestCase
         | 
| 115 128 | 
             
              test "multiline expressions should work" do
         | 
| 116 129 | 
             
                html = "foobarbaz\n"
         | 
| 117 130 | 
             
                haml = %Q{:erb\n  <%= "foo" +\n      "bar" +\n      "baz" %>}
         | 
| @@ -132,7 +145,7 @@ class ErbFilterTest < MiniTest::Unit::TestCase | |
| 132 145 |  | 
| 133 146 | 
             
            end
         | 
| 134 147 |  | 
| 135 | 
            -
            class JavascriptFilterTest <  | 
| 148 | 
            +
            class JavascriptFilterTest < Haml::TestCase
         | 
| 136 149 | 
             
              test "should interpolate" do
         | 
| 137 150 | 
             
                scope = Object.new.instance_eval {foo = "bar"; nil if foo; binding}
         | 
| 138 151 | 
             
                haml  = ":javascript\n  \#{foo}"
         | 
| @@ -140,8 +153,8 @@ class JavascriptFilterTest < MiniTest::Unit::TestCase | |
| 140 153 | 
             
                assert_match(/bar/, html)
         | 
| 141 154 | 
             
              end
         | 
| 142 155 |  | 
| 143 | 
            -
              test "should never HTML-escape ampersands" do
         | 
| 144 | 
            -
                html = "<script>\n  & < >  | 
| 156 | 
            +
              test "should never HTML-escape non-interpolated ampersands" do
         | 
| 157 | 
            +
                html = "<script>\n  & < > &\n</script>\n"
         | 
| 145 158 | 
             
                haml = %Q{:javascript\n  & < > \#{"&"}}
         | 
| 146 159 | 
             
                assert_equal(html, render(haml, :escape_html => true))
         | 
| 147 160 | 
             
              end
         | 
| @@ -178,7 +191,7 @@ class JavascriptFilterTest < MiniTest::Unit::TestCase | |
| 178 191 | 
             
              end
         | 
| 179 192 | 
             
            end
         | 
| 180 193 |  | 
| 181 | 
            -
            class CSSFilterTest <  | 
| 194 | 
            +
            class CSSFilterTest < Haml::TestCase
         | 
| 182 195 | 
             
              test "should wrap output in CDATA and a CSS tag when output is XHTML" do
         | 
| 183 196 | 
             
                html = "<style type='text/css'>\n  /*<![CDATA[*/\n    foo\n  /*]]>*/\n</style>\n"
         | 
| 184 197 | 
             
                haml = ":css\n  foo"
         | 
| @@ -217,7 +230,7 @@ class CSSFilterTest < MiniTest::Unit::TestCase | |
| 217 230 | 
             
              end
         | 
| 218 231 | 
             
            end
         | 
| 219 232 |  | 
| 220 | 
            -
            class CDATAFilterTest <  | 
| 233 | 
            +
            class CDATAFilterTest < Haml::TestCase
         | 
| 221 234 | 
             
              test "should wrap output in CDATA tag" do
         | 
| 222 235 | 
             
                html = "<![CDATA[\n    foo\n]]>\n"
         | 
| 223 236 | 
             
                haml = ":cdata\n  foo"
         | 
| @@ -225,7 +238,7 @@ class CDATAFilterTest < MiniTest::Unit::TestCase | |
| 225 238 | 
             
              end
         | 
| 226 239 | 
             
            end
         | 
| 227 240 |  | 
| 228 | 
            -
            class EscapedFilterTest <  | 
| 241 | 
            +
            class EscapedFilterTest < Haml::TestCase
         | 
| 229 242 | 
             
              test "should escape ampersands" do
         | 
| 230 243 | 
             
                html = "&\n"
         | 
| 231 244 | 
             
                haml = ":escaped\n  &"
         | 
| @@ -233,7 +246,7 @@ class EscapedFilterTest < MiniTest::Unit::TestCase | |
| 233 246 | 
             
              end
         | 
| 234 247 | 
             
            end
         | 
| 235 248 |  | 
| 236 | 
            -
            class RubyFilterTest <  | 
| 249 | 
            +
            class RubyFilterTest < Haml::TestCase
         | 
| 237 250 | 
             
              test "can write to haml_io" do
         | 
| 238 251 | 
             
                haml = ":ruby\n  haml_io.puts 'hello'\n"
         | 
| 239 252 | 
             
                html = "hello\n"
         | 
| @@ -251,4 +264,4 @@ class RubyFilterTest < MiniTest::Unit::TestCase | |
| 251 264 | 
             
                html = "7\n"
         | 
| 252 265 | 
             
                assert_equal(html, render(haml))
         | 
| 253 266 | 
             
              end
         | 
| 254 | 
            -
            end
         | 
| 267 | 
            +
            end
         | 
| @@ -0,0 +1,87 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: ../..
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                haml (4.0.7)
         | 
| 5 | 
            +
                  tilt
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            GEM
         | 
| 8 | 
            +
              remote: http://rubygems.org/
         | 
| 9 | 
            +
              specs:
         | 
| 10 | 
            +
                actionmailer (4.0.13)
         | 
| 11 | 
            +
                  actionpack (= 4.0.13)
         | 
| 12 | 
            +
                  mail (~> 2.5, >= 2.5.4)
         | 
| 13 | 
            +
                actionpack (4.0.13)
         | 
| 14 | 
            +
                  activesupport (= 4.0.13)
         | 
| 15 | 
            +
                  builder (~> 3.1.0)
         | 
| 16 | 
            +
                  erubis (~> 2.7.0)
         | 
| 17 | 
            +
                  rack (~> 1.5.2)
         | 
| 18 | 
            +
                  rack-test (~> 0.6.2)
         | 
| 19 | 
            +
                activemodel (4.0.13)
         | 
| 20 | 
            +
                  activesupport (= 4.0.13)
         | 
| 21 | 
            +
                  builder (~> 3.1.0)
         | 
| 22 | 
            +
                activerecord (4.0.13)
         | 
| 23 | 
            +
                  activemodel (= 4.0.13)
         | 
| 24 | 
            +
                  activerecord-deprecated_finders (~> 1.0.2)
         | 
| 25 | 
            +
                  activesupport (= 4.0.13)
         | 
| 26 | 
            +
                  arel (~> 4.0.0)
         | 
| 27 | 
            +
                activerecord-deprecated_finders (1.0.4)
         | 
| 28 | 
            +
                activesupport (4.0.13)
         | 
| 29 | 
            +
                  i18n (~> 0.6, >= 0.6.9)
         | 
| 30 | 
            +
                  minitest (~> 4.2)
         | 
| 31 | 
            +
                  multi_json (~> 1.3)
         | 
| 32 | 
            +
                  thread_safe (~> 0.1)
         | 
| 33 | 
            +
                  tzinfo (~> 0.3.37)
         | 
| 34 | 
            +
                arel (4.0.2)
         | 
| 35 | 
            +
                builder (3.1.4)
         | 
| 36 | 
            +
                concurrent-ruby (1.0.2)
         | 
| 37 | 
            +
                erubis (2.7.0)
         | 
| 38 | 
            +
                i18n (0.7.0)
         | 
| 39 | 
            +
                mail (2.6.4)
         | 
| 40 | 
            +
                  mime-types (>= 1.16, < 4)
         | 
| 41 | 
            +
                mime-types (2.99.2)
         | 
| 42 | 
            +
                minitest (4.7.5)
         | 
| 43 | 
            +
                multi_json (1.12.1)
         | 
| 44 | 
            +
                nokogiri (1.5.11)
         | 
| 45 | 
            +
                rack (1.5.5)
         | 
| 46 | 
            +
                rack-test (0.6.3)
         | 
| 47 | 
            +
                  rack (>= 1.0)
         | 
| 48 | 
            +
                rails (4.0.13)
         | 
| 49 | 
            +
                  actionmailer (= 4.0.13)
         | 
| 50 | 
            +
                  actionpack (= 4.0.13)
         | 
| 51 | 
            +
                  activerecord (= 4.0.13)
         | 
| 52 | 
            +
                  activesupport (= 4.0.13)
         | 
| 53 | 
            +
                  bundler (>= 1.3.0, < 2.0)
         | 
| 54 | 
            +
                  railties (= 4.0.13)
         | 
| 55 | 
            +
                  sprockets-rails (~> 2.0)
         | 
| 56 | 
            +
                railties (4.0.13)
         | 
| 57 | 
            +
                  actionpack (= 4.0.13)
         | 
| 58 | 
            +
                  activesupport (= 4.0.13)
         | 
| 59 | 
            +
                  rake (>= 0.8.7)
         | 
| 60 | 
            +
                  thor (>= 0.18.1, < 2.0)
         | 
| 61 | 
            +
                rake (11.2.2)
         | 
| 62 | 
            +
                rbench (0.2.3)
         | 
| 63 | 
            +
                sprockets (3.7.0)
         | 
| 64 | 
            +
                  concurrent-ruby (~> 1.0)
         | 
| 65 | 
            +
                  rack (> 1, < 3)
         | 
| 66 | 
            +
                sprockets-rails (2.3.3)
         | 
| 67 | 
            +
                  actionpack (>= 3.0)
         | 
| 68 | 
            +
                  activesupport (>= 3.0)
         | 
| 69 | 
            +
                  sprockets (>= 2.8, < 4.0)
         | 
| 70 | 
            +
                thor (0.19.1)
         | 
| 71 | 
            +
                thread_safe (0.3.5)
         | 
| 72 | 
            +
                tilt (2.0.5)
         | 
| 73 | 
            +
                tzinfo (0.3.51)
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            PLATFORMS
         | 
| 76 | 
            +
              ruby
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            DEPENDENCIES
         | 
| 79 | 
            +
              haml!
         | 
| 80 | 
            +
              mime-types (< 3)
         | 
| 81 | 
            +
              minitest
         | 
| 82 | 
            +
              nokogiri (~> 1.5.10)
         | 
| 83 | 
            +
              rails (~> 4.0.0)
         | 
| 84 | 
            +
              rbench
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            BUNDLED WITH
         | 
| 87 | 
            +
               1.12.5
         |