Closed sandrodz closed 7 years ago
Indeed class is a reserved keyword. In JS attributes.class
is forbidden. But it would be fine to make an exception for class preceeded by .
Is it a quick fix?
Yes, released, please do composer update
and tell me if all is fine for you?
Works great, thanks!
After some testing, I noticed in nodejs behavior is different.
In node, class="u-pos-a u-lt-0 u-tp-0"
is overwritten by class=attributes.class
only when class
is defined like so: +bg-el-flour(class="u-unmt-s u-z-beta")
.
If you do +bg-el-flour
without class than default class="u-pos-a u-lt-0 u-tp-0"
stays.
in case of pug-php - class="u-pos-a u-lt-0 u-tp-0"
disappears all the time. even in case of +bg-el-flour
hm, was my description clear?
Where come from the overwritten class? Could you post the mixin declaration?
Mixin:
mixin bg-el-flour
div(class="u-pos-a u-lt-0 u-tp-0" class=attributes.class style="background:url("+assets_url+"/images/bg-el-flour.png) left top/contain no-repeat; width:calc(2.78vw*4); height:calc(3.47vw*4); max-width:27.8rem; max-height:34.7rem")
+bg-el-flour
should return div with class u-pos-a u-lt-0 u-tp-0
+bg-el-flour(class="whatever-class-this-is")
should return div with class whatever-class-this-is
instead of default u-pos-a u-lt-0 u-tp-0
We discussed a lot about attribute merging for pug-php 3.0. There will be options for that since this is not really reliable to concat, if the template does not ask for it explicitly. Have twice the same attribute in HTML is a bad practice. Pug can ease the way it's handled but it's still a bad practice. However you can hack it this way:
mixin bg-el-flour
div(class=attributes.class . " ab cd")
+bg-el-flour.ef.gh
+bg-el-flour
hack example is not clear to me, how would I do: +bg-el-flour(class="whatever-class-this-is")
?
There is no problem with your example, it's exactly the same as using the dot. You get the classes merged, see the demo: https://pug-demo.herokuapp.com/
Okay, works! thanks.
Fatal error: Uncaught JsPhpize\Parser\Exception: Unexpected keyword class in on line 1 near from class in /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/TokenCrawler.php:40 Stack trace: #0 /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/TokenExtractor.php(42): JsPhpize\Parser\TokenCrawler->unexpected(Object(JsPhpize\Lexer\Token)) #1 /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/Parser.php(181): JsPhpize\Parser\TokenExtractor->getVariableChildFromToken(Object(JsPhpize\Lexer\Token)) #2 /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/Parser.php(227): JsPhpize\Parser\Parser->parseVariable('attributes') #3 /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/TokenExtractor.php(129): JsPhpize\Parser\Parser->parseValue(Object(JsPhpize\Lexer\Token)) #4 /www/lithuanianbakery.dev/vendor/js-phpize/js-phpize/src/JsPhpize/Parser/TokenExtractor.php(82): JsPhpize\Parser\TokenExtractor->getInitialValue(Object(JsPhpi in /www/lithuanianbakery.dev/vendor/pug-php/pug/src/Jade/Compiler/Visitor.php on line 52