Last active
January 15, 2021 18:20
-
-
Save OZZlE/f635bbff3ab15b4d433c9c0310956957 to your computer and use it in GitHub Desktop.
PHP equivalent of "modern" sass/less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// index.php | |
/* We assume that a designer will ask us one day to increase/decrease all body texts | |
this website was made in 2010 and we're changing platform now but "sure" this is | |
going to happen soon :D "In the next project" :-d | |
Also Search & replace '1em' is very trixy, cannot be done reaaallly! IMPOSSIBLE! | |
*/ | |
$GLOBALS['fontSizeDefault'] = '1em'; | |
class MixinC { // ... } | |
class MixinB extends MixinC { // ... } | |
class MixinA extends MixinB { // ... } | |
// controller/routeX.php | |
$GLOBALS['fontSizeDefaultCurrent'] = $GLOBALS['fontSizeDefault']; | |
// Component.php | |
$GLOBALS['fontSizeDefaultCurrentPage'] = $GLOBALS['fontSizeDefaultCurrent']; | |
class Component extends MixinA | |
{ | |
public $fontSize = $GLOBALS['fontSizeDefaultCurrentPage']; | |
public __construct() { | |
// damn... designer wanted different for this component | |
// lets undo all these cool useful mixins and variables | |
$this->fontSize = '1.2em'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, one should never do that. But you can produce bad code with any language. I think both Sass and Less warn in documentation to be careful with deep nesting (or they should).