faml 0.6.4 → 0.6.5
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/ext/attribute_builder/attribute_builder.c +26 -15
- data/incompatibilities/README.md +1 -1
- data/incompatibilities/spec/render/attribute_spec.md +59 -19
- data/incompatibilities/spec/render/hash_attribute_spec.md +21 -0
- data/lib/faml/attribute_compiler.rb +0 -2
- data/lib/faml/attribute_optimizer.rb +3 -4
- data/lib/faml/version.rb +1 -1
- data/spec/render/attribute_spec.rb +14 -0
- data/spec/render/hash_attribute_spec.rb +8 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 12548082a8aaf67316ba96345010c92ded15aa41
         | 
| 4 | 
            +
              data.tar.gz: bf0e80233a7227814421df27fe15b8fe05271aad
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 13d98c0fd7b3fa67895b874a99bc02606e3eb334be9d169038d975f86f09c7715f602a94d577ea63ef9ae7222795fbe7987555a6cfd8bd104216722ad6ef2765
         | 
| 7 | 
            +
              data.tar.gz: 2ac8f294c6bfe8eab1ace2a755f6f5eceff9fd0b59770653a0d8c321c300a876d09f105e7d4f09d7dd1a130015588ea10fb05bd689bd6b3adfb90ae844fa8d3c
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,11 @@ | |
| 1 | 
            +
            ## 0.6.5 (2015-11-28)
         | 
| 2 | 
            +
            - Delete falsey values after merging all attributes
         | 
| 3 | 
            +
                - `%span(foo=true){foo: false}` now renders `<span></span>`, because old attributes have priority even if the value is falsey.
         | 
| 4 | 
            +
                - https://github.com/eagletmt/faml/pull/43
         | 
| 5 | 
            +
            - Fix duplicated attribute in dynamic attribute
         | 
| 6 | 
            +
                - `%span{foo: 1, 'foo' => 1+1}` now renders `<span foo='2'></span>` correctly
         | 
| 7 | 
            +
                - https://github.com/eagletmt/faml/pull/45
         | 
| 8 | 
            +
             | 
| 1 9 | 
             
            ## 0.6.4 (2015-11-28)
         | 
| 2 10 | 
             
            - Flatten `id` and `class` attributes
         | 
| 3 11 | 
             
                - https://github.com/eagletmt/faml/pull/41
         | 
| @@ -83,14 +83,12 @@ substitute_underscores(VALUE str) | |
| 83 83 | 
             
            static int
         | 
| 84 84 | 
             
            normalize_data_i2(VALUE key, VALUE value, VALUE ptr)
         | 
| 85 85 | 
             
            {
         | 
| 86 | 
            -
               | 
| 87 | 
            -
             | 
| 88 | 
            -
                VALUE k = rb_str_dup(arg->key);
         | 
| 86 | 
            +
              struct normalize_data_i2_arg *arg = (struct normalize_data_i2_arg *)ptr;
         | 
| 87 | 
            +
              VALUE k = rb_str_dup(arg->key);
         | 
| 89 88 |  | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
              }
         | 
| 89 | 
            +
              rb_str_cat(k, "-", 1);
         | 
| 90 | 
            +
              rb_str_append(k, key);
         | 
| 91 | 
            +
              rb_hash_aset(arg->normalized, k, value);
         | 
| 94 92 | 
             
              return ST_CONTINUE;
         | 
| 95 93 | 
             
            }
         | 
| 96 94 |  | 
| @@ -107,11 +105,9 @@ normalize_data_i(VALUE key, VALUE value, VALUE normalized) | |
| 107 105 | 
             
                arg.key = key;
         | 
| 108 106 | 
             
                arg.normalized = normalized;
         | 
| 109 107 | 
             
                rb_hash_foreach(normalize_data(value), FOREACH_FUNC(normalize_data_i2), (VALUE)(&arg));
         | 
| 110 | 
            -
              } else if (RB_TYPE_P(value, T_TRUE)) {
         | 
| 111 | 
            -
                /* Keep Qtrue value */
         | 
| 108 | 
            +
              } else if (RB_TYPE_P(value, T_TRUE) || !RTEST(value)) {
         | 
| 109 | 
            +
                /* Keep Qtrue and falsey value */
         | 
| 112 110 | 
             
                rb_hash_aset(normalized, key, value);
         | 
| 113 | 
            -
              } else if (!RTEST(value)) {
         | 
| 114 | 
            -
                /* Delete falsey values */
         | 
| 115 111 | 
             
              } else {
         | 
| 116 112 | 
             
                rb_hash_aset(normalized, key, rb_convert_type(value, T_STRING, "String", "to_s"));
         | 
| 117 113 | 
             
              }
         | 
| @@ -157,10 +153,8 @@ normalize(VALUE hash) | |
| 157 153 | 
             
                  rb_hash_delete(hash, key);
         | 
| 158 154 | 
             
                  data = normalize_data(value);
         | 
| 159 155 | 
             
                  rb_hash_foreach(data, FOREACH_FUNC(put_data_attribute), hash);
         | 
| 160 | 
            -
                } else if (RB_TYPE_P(value, T_TRUE)) {
         | 
| 161 | 
            -
                  /* Keep Qtrue value */
         | 
| 162 | 
            -
                } else if (!RTEST(value)) {
         | 
| 163 | 
            -
                  rb_hash_delete(hash, key);
         | 
| 156 | 
            +
                } else if (RB_TYPE_P(value, T_TRUE) || !RTEST(value)) {
         | 
| 157 | 
            +
                  /* Keep Qtrue and falsey value */
         | 
| 164 158 | 
             
                } else {
         | 
| 165 159 | 
             
                  rb_hash_aset(hash, key, rb_convert_type(value, T_STRING, "String", "to_s"));
         | 
| 166 160 | 
             
                }
         | 
| @@ -226,6 +220,22 @@ join_id_attribute(VALUE attributes, VALUE key) | |
| 226 220 | 
             
              }
         | 
| 227 221 | 
             
            }
         | 
| 228 222 |  | 
| 223 | 
            +
            static int
         | 
| 224 | 
            +
            delete_falsey_values_i(RB_UNUSED_VAR(VALUE key), VALUE value, RB_UNUSED_VAR(VALUE arg))
         | 
| 225 | 
            +
            {
         | 
| 226 | 
            +
              if (RTEST(value)) {
         | 
| 227 | 
            +
                return ST_CONTINUE;
         | 
| 228 | 
            +
              } else {
         | 
| 229 | 
            +
                return ST_DELETE;
         | 
| 230 | 
            +
              }
         | 
| 231 | 
            +
            }
         | 
| 232 | 
            +
             | 
| 233 | 
            +
            static void
         | 
| 234 | 
            +
            delete_falsey_values(VALUE attributes)
         | 
| 235 | 
            +
            {
         | 
| 236 | 
            +
              rb_hash_foreach(attributes, FOREACH_FUNC(delete_falsey_values_i), Qnil);
         | 
| 237 | 
            +
            }
         | 
| 238 | 
            +
             | 
| 229 239 | 
             
            static VALUE
         | 
| 230 240 | 
             
            merge(VALUE object_ref, int argc, VALUE *argv)
         | 
| 231 241 | 
             
            {
         | 
| @@ -247,6 +257,7 @@ merge(VALUE object_ref, int argc, VALUE *argv) | |
| 247 257 |  | 
| 248 258 | 
             
              join_class_attribute(attributes, class_str);
         | 
| 249 259 | 
             
              join_id_attribute(attributes, id_str);
         | 
| 260 | 
            +
              delete_falsey_values(attributes);
         | 
| 250 261 |  | 
| 251 262 | 
             
              return attributes;
         | 
| 252 263 | 
             
            }
         | 
    
        data/incompatibilities/README.md
    CHANGED
    
    
| @@ -1,6 +1,46 @@ | |
| 1 1 | 
             
            # [./spec/render/attribute_spec.rb:44](../../../spec/render/attribute_spec.rb#L44)
         | 
| 2 2 | 
             
            ## Input
         | 
| 3 3 | 
             
            ```haml
         | 
| 4 | 
            +
            - h1 = { foo: 'should be overwritten' }
         | 
| 5 | 
            +
            - h2 = { foo: nil }
         | 
| 6 | 
            +
            %a{h1, h2}
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ```
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ## Faml, Haml
         | 
| 11 | 
            +
            ```html
         | 
| 12 | 
            +
            <a></a>
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ```
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            ## Hamlit
         | 
| 17 | 
            +
            ```html
         | 
| 18 | 
            +
            <a foo='should be overwritten'></a>
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            ```
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            # [./spec/render/attribute_spec.rb:52](../../../spec/render/attribute_spec.rb#L52)
         | 
| 23 | 
            +
            ## Input
         | 
| 24 | 
            +
            ```haml
         | 
| 25 | 
            +
            - h = {foo: 1, 'foo' => 2}
         | 
| 26 | 
            +
            %span{h}
         | 
| 27 | 
            +
            ```
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            ## Faml, Haml
         | 
| 30 | 
            +
            ```html
         | 
| 31 | 
            +
            <span foo='2'></span>
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ```
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            ## Hamlit
         | 
| 36 | 
            +
            ```html
         | 
| 37 | 
            +
            <span foo='1' foo='2'></span>
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ```
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # [./spec/render/attribute_spec.rb:58](../../../spec/render/attribute_spec.rb#L58)
         | 
| 42 | 
            +
            ## Input
         | 
| 43 | 
            +
            ```haml
         | 
| 4 44 | 
             
            %span{foo: "x\"y'z"}hello
         | 
| 5 45 | 
             
            ```
         | 
| 6 46 |  | 
| @@ -16,7 +56,7 @@ | |
| 16 56 |  | 
| 17 57 | 
             
            ```
         | 
| 18 58 |  | 
| 19 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 59 | 
            +
            # [./spec/render/attribute_spec.rb:58](../../../spec/render/attribute_spec.rb#L58)
         | 
| 20 60 | 
             
            ## Input
         | 
| 21 61 | 
             
            ```haml
         | 
| 22 62 | 
             
            - v = "x\"y'z"
         | 
| @@ -35,7 +75,7 @@ | |
| 35 75 |  | 
| 36 76 | 
             
            ```
         | 
| 37 77 |  | 
| 38 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 78 | 
            +
            # [./spec/render/attribute_spec.rb:58](../../../spec/render/attribute_spec.rb#L58)
         | 
| 39 79 | 
             
            ## Input
         | 
| 40 80 | 
             
            ```haml
         | 
| 41 81 | 
             
            - h = {foo: "x\"y'z"}
         | 
| @@ -54,7 +94,7 @@ | |
| 54 94 |  | 
| 55 95 | 
             
            ```
         | 
| 56 96 |  | 
| 57 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 97 | 
            +
            # [./spec/render/attribute_spec.rb:75](../../../spec/render/attribute_spec.rb#L75)
         | 
| 58 98 | 
             
            ## Input (with options={:format=>:xhtml})
         | 
| 59 99 | 
             
            ```haml
         | 
| 60 100 | 
             
            - v = true
         | 
| @@ -73,7 +113,7 @@ | |
| 73 113 |  | 
| 74 114 | 
             
            ```
         | 
| 75 115 |  | 
| 76 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 116 | 
            +
            # [./spec/render/attribute_spec.rb:75](../../../spec/render/attribute_spec.rb#L75)
         | 
| 77 117 | 
             
            ## Input (with options={:format=>:xhtml})
         | 
| 78 118 | 
             
            ```haml
         | 
| 79 119 | 
             
            - h = {foo: true}
         | 
| @@ -92,7 +132,7 @@ | |
| 92 132 |  | 
| 93 133 | 
             
            ```
         | 
| 94 134 |  | 
| 95 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 135 | 
            +
            # [./spec/render/attribute_spec.rb:89](../../../spec/render/attribute_spec.rb#L89)
         | 
| 96 136 | 
             
            ## Input
         | 
| 97 137 | 
             
            ```haml
         | 
| 98 138 | 
             
            %span{b: __LINE__,
         | 
| @@ -112,7 +152,7 @@ | |
| 112 152 |  | 
| 113 153 | 
             
            ```
         | 
| 114 154 |  | 
| 115 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 155 | 
            +
            # [./spec/render/attribute_spec.rb:96](../../../spec/render/attribute_spec.rb#L96)
         | 
| 116 156 | 
             
            ## Input
         | 
| 117 157 | 
             
            ```haml
         | 
| 118 158 | 
             
            %span{"foo\0bar" => "hello"}
         | 
| @@ -130,7 +170,7 @@ | |
| 130 170 |  | 
| 131 171 | 
             
            ```
         | 
| 132 172 |  | 
| 133 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 173 | 
            +
            # [./spec/render/attribute_spec.rb:96](../../../spec/render/attribute_spec.rb#L96)
         | 
| 134 174 | 
             
            ## Input
         | 
| 135 175 | 
             
            ```haml
         | 
| 136 176 | 
             
            - val = "hello"
         | 
| @@ -150,7 +190,7 @@ | |
| 150 190 |  | 
| 151 191 | 
             
            ```
         | 
| 152 192 |  | 
| 153 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 193 | 
            +
            # [./spec/render/attribute_spec.rb:96](../../../spec/render/attribute_spec.rb#L96)
         | 
| 154 194 | 
             
            ## Input
         | 
| 155 195 | 
             
            ```haml
         | 
| 156 196 | 
             
            - key = "foo\0bar"
         | 
| @@ -172,7 +212,7 @@ | |
| 172 212 | 
             
            ...                               ^
         | 
| 173 213 | 
             
            ```
         | 
| 174 214 |  | 
| 175 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 215 | 
            +
            # [./spec/render/attribute_spec.rb:110](../../../spec/render/attribute_spec.rb#L110)
         | 
| 176 216 | 
             
            ## Input
         | 
| 177 217 | 
             
            ```haml
         | 
| 178 218 | 
             
            %span[Faml::TestStruct.new(123)] hello
         | 
| @@ -190,7 +230,7 @@ | |
| 190 230 |  | 
| 191 231 | 
             
            ```
         | 
| 192 232 |  | 
| 193 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 233 | 
            +
            # [./spec/render/attribute_spec.rb:114](../../../spec/render/attribute_spec.rb#L114)
         | 
| 194 234 | 
             
            ## Input
         | 
| 195 235 | 
             
            ```haml
         | 
| 196 236 | 
             
            %span[Faml::TestStruct.new(123), :hello] hello
         | 
| @@ -208,7 +248,7 @@ | |
| 208 248 |  | 
| 209 249 | 
             
            ```
         | 
| 210 250 |  | 
| 211 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 251 | 
            +
            # [./spec/render/attribute_spec.rb:118](../../../spec/render/attribute_spec.rb#L118)
         | 
| 212 252 | 
             
            ## Input
         | 
| 213 253 | 
             
            ```haml
         | 
| 214 254 | 
             
            %span[Faml::TestRefStruct.new(123)] hello
         | 
| @@ -226,7 +266,7 @@ | |
| 226 266 |  | 
| 227 267 | 
             
            ```
         | 
| 228 268 |  | 
| 229 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 269 | 
            +
            # [./spec/render/attribute_spec.rb:122](../../../spec/render/attribute_spec.rb#L122)
         | 
| 230 270 | 
             
            ## Input
         | 
| 231 271 | 
             
            ```haml
         | 
| 232 272 | 
             
            %span#baz[Faml::TestStruct.new(123)]{id: "foo"} hello
         | 
| @@ -244,7 +284,7 @@ | |
| 244 284 |  | 
| 245 285 | 
             
            ```
         | 
| 246 286 |  | 
| 247 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 287 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 248 288 | 
             
            ## Input
         | 
| 249 289 | 
             
            ```haml
         | 
| 250 290 | 
             
            %span{foo: 1}(foo=2)
         | 
| @@ -262,7 +302,7 @@ | |
| 262 302 |  | 
| 263 303 | 
             
            ```
         | 
| 264 304 |  | 
| 265 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 305 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 266 306 | 
             
            ## Input
         | 
| 267 307 | 
             
            ```haml
         | 
| 268 308 | 
             
            %span(foo=2){foo: 1}
         | 
| @@ -280,7 +320,7 @@ | |
| 280 320 |  | 
| 281 321 | 
             
            ```
         | 
| 282 322 |  | 
| 283 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 323 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 284 324 | 
             
            ## Input
         | 
| 285 325 | 
             
            ```haml
         | 
| 286 326 | 
             
            - v = 2
         | 
| @@ -299,7 +339,7 @@ | |
| 299 339 |  | 
| 300 340 | 
             
            ```
         | 
| 301 341 |  | 
| 302 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 342 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 303 343 | 
             
            ## Input
         | 
| 304 344 | 
             
            ```haml
         | 
| 305 345 | 
             
            - v = 2
         | 
| @@ -318,7 +358,7 @@ | |
| 318 358 |  | 
| 319 359 | 
             
            ```
         | 
| 320 360 |  | 
| 321 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 361 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 322 362 | 
             
            ## Input
         | 
| 323 363 | 
             
            ```haml
         | 
| 324 364 | 
             
            - h = {foo: 1}
         | 
| @@ -337,7 +377,7 @@ | |
| 337 377 |  | 
| 338 378 | 
             
            ```
         | 
| 339 379 |  | 
| 340 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 380 | 
            +
            # [./spec/render/attribute_spec.rb:128](../../../spec/render/attribute_spec.rb#L128)
         | 
| 341 381 | 
             
            ## Input
         | 
| 342 382 | 
             
            ```haml
         | 
| 343 383 | 
             
            - h = {foo: 1}
         | 
| @@ -356,7 +396,7 @@ | |
| 356 396 |  | 
| 357 397 | 
             
            ```
         | 
| 358 398 |  | 
| 359 | 
            -
            # [./spec/render/attribute_spec.rb: | 
| 399 | 
            +
            # [./spec/render/attribute_spec.rb:147](../../../spec/render/attribute_spec.rb#L147)
         | 
| 360 400 | 
             
            ## Input
         | 
| 361 401 | 
             
            ```haml
         | 
| 362 402 | 
             
            %span{id: 1}(id=2)
         | 
| @@ -118,3 +118,24 @@ | |
| 118 118 |  | 
| 119 119 | 
             
            ```
         | 
| 120 120 |  | 
| 121 | 
            +
            # [./spec/render/hash_attribute_spec.rb:61](../../../spec/render/hash_attribute_spec.rb#L61)
         | 
| 122 | 
            +
            ## Input
         | 
| 123 | 
            +
            ```haml
         | 
| 124 | 
            +
            - h1 = { new: true }
         | 
| 125 | 
            +
            - h2 = { data: { old: true } }
         | 
| 126 | 
            +
            %a(data=h1){ h2 , data: { new: nil, old: false } }
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            ```
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            ## Faml, Haml
         | 
| 131 | 
            +
            ```html
         | 
| 132 | 
            +
            <a></a>
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            ```
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            ## Hamlit
         | 
| 137 | 
            +
            ```html
         | 
| 138 | 
            +
            <a data-old data='{:new=>true}'></a>
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            ```
         | 
| 141 | 
            +
             | 
| @@ -59,10 +59,9 @@ module Faml | |
| 59 59 | 
             
                  parser.dynamic_attributes.each do |k, v|
         | 
| 60 60 | 
             
                    k = k.to_s
         | 
| 61 61 | 
             
                    if static_attributes.key?(k)
         | 
| 62 | 
            -
                       | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
                      end
         | 
| 62 | 
            +
                      # XXX: Quit optimization.
         | 
| 63 | 
            +
                      # See also https://github.com/eagletmt/faml/issues/44
         | 
| 64 | 
            +
                      return nil
         | 
| 66 65 | 
             
                    end
         | 
| 67 66 | 
             
                    dynamic_attributes[k] = v
         | 
| 68 67 | 
             
                  end
         | 
    
        data/lib/faml/version.rb
    CHANGED
    
    
| @@ -41,6 +41,20 @@ RSpec.describe 'Attributes rendering', type: :render do | |
| 41 41 | 
             
                end
         | 
| 42 42 | 
             
              end
         | 
| 43 43 |  | 
| 44 | 
            +
              it 'skips falsey values after merging attributes' do
         | 
| 45 | 
            +
                expect(render_string(<<HAML)).to eq("<a></a>\n")
         | 
| 46 | 
            +
            - h1 = { foo: 'should be overwritten' }
         | 
| 47 | 
            +
            - h2 = { foo: nil }
         | 
| 48 | 
            +
            %a{h1, h2}
         | 
| 49 | 
            +
            HAML
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              it 'renders duplicated keys correctly' do
         | 
| 53 | 
            +
                expect(render_string("%span{foo: 1, 'foo' => 2}")).to eq("<span foo='2'></span>\n")
         | 
| 54 | 
            +
                expect(render_string("- v = 2\n%span{foo: 1, 'foo' => v}")).to eq("<span foo='2'></span>\n")
         | 
| 55 | 
            +
                expect(render_string("- h = {foo: 1, 'foo' => 2}\n%span{h}")).to eq("<span foo='2'></span>\n")
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 44 58 | 
             
              it 'escapes' do
         | 
| 45 59 | 
             
                with_each_attribute_type(:foo, %q|"x\"y'z"|, text: 'hello') do |str|
         | 
| 46 60 | 
             
                  expect(render_string(str)).to eq(%Q{<span foo='x"y'z'>hello</span>\n})
         | 
| @@ -58,6 +58,14 @@ HAML | |
| 58 58 | 
             
                  expect(render_string("- v = nil\n%span{data: { foo: v }}")).to eq("<span></span>\n")
         | 
| 59 59 | 
             
                end
         | 
| 60 60 |  | 
| 61 | 
            +
                it 'skips falsey data attributes after merging attributes' do
         | 
| 62 | 
            +
                  expect(render_string(<<HAML)).to eq("<a></a>\n")
         | 
| 63 | 
            +
            - h1 = { new: true }
         | 
| 64 | 
            +
            - h2 = { data: { old: true } }
         | 
| 65 | 
            +
            %a(data=h1){ h2 , data: { new: nil, old: false } }
         | 
| 66 | 
            +
            HAML
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 61 69 | 
             
                it 'renders true data attributes' do
         | 
| 62 70 | 
             
                  expect(render_string('%span{data: { foo: true }}')).to eq("<span data-foo></span>\n")
         | 
| 63 71 | 
             
                  expect(render_string("- v = true\n%span{data: { foo: v }}")).to eq("<span data-foo></span>\n")
         |