bernhard Posted January 13, 2019 Share Posted January 13, 2019 RockLESS Download: https://modules.processwire.com/modules/rock-less/ Docs: https://github.com/BernhardBaumrock/RockLESS 9 Link to comment Share on other sites More sharing options...
porl Posted February 3, 2020 Share Posted February 3, 2020 Where did you get the Less compiler part from? I noticed some warnings from php regarding the use of "continue" rather than "break" in some switch statements (functionally identical but continue generates a warning). I saw they were from the less.php/Less.php file and was about to patch them, however I was curious as to whether this was imported from an external library or you rolled your own. If external then I would imagine it more useful to fix it upstream first. I did a brief search for "less.php" but didn't find anything that seemed to match your project file's structure. Link to comment Share on other sites More sharing options...
bernhard Posted March 3, 2020 Author Share Posted March 3, 2020 Hi @porl sorry for the delay! It's this one: https://github.com/oyejorge/less.php I see that the repository is archived/read-only. Maybe you want to fork it and I can include the fixed version? Or we can take one of the 186 available forks ? https://github.com/oyejorge/less.php/network/members; maybe https://github.com/wikimedia/less.php ? Link to comment Share on other sites More sharing options...
porl Posted March 4, 2020 Share Posted March 4, 2020 @bernhard I definitely think a more active fork makes sense. If one of use were to fork it for this one-off I think a similar problem would just happen again in future. Link to comment Share on other sites More sharing options...
bernhard Posted March 4, 2020 Author Share Posted March 4, 2020 @porl could you please try if the fork linked above resolves your problem? It has a very active commit log and 72 contributors so that should be a solid choice. Link to comment Share on other sites More sharing options...
porl Posted March 8, 2020 Share Posted March 8, 2020 @bernhard I'll be happy to when I get a chance. Unfortunately I'm in the middle of a project I have severely underestimated time-wise so I'm not sure when I'll get to it sorry. If you don't get anything useful from me in the near future make sure to ping me again and I'll try to get back to it! Link to comment Share on other sites More sharing options...
porl Posted March 22, 2020 Share Posted March 22, 2020 @bernhard I have started a quick test and so far so good. The wikimedia fork is structured differently but I copied the "lib/Less" directory into the RockLESS one (so there is /RockLESS/Less) and modified the RockLESS.module.php file as follows: diff --git a/site/modules/RockLESS/RockLESS.module.php b/site/modules/RockLESS/RockLESS.module.php index a711627..fd455da 100644 --- a/site/modules/RockLESS/RockLESS.module.php +++ b/site/modules/RockLESS/RockLESS.module.php @@ -23,7 +23,10 @@ class RockLESS extends WireData implements Module { public function init() { // load less.php if it is not already loaded // a simple require_once does not work properly - if(!class_exists('Less_Parser')) require_once(__DIR__ . "/less.php/Less.php"); + if(!class_exists('Less_Parser')) { + require_once(__DIR__ . "/Less/Autoloader.php"); + \Less_Autoloader::register(); + } } /** A quick check and the RockSkinUIKit module loads and executes with no more errors. I'm not using the RockLESS module beyond that in this project but I assume that is a sign that it should work as expected. 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 22, 2020 Author Share Posted March 22, 2020 Thx @porl I've tested the fork locally without any issues, so I just pushed the update and bumped version to 0.0.2 ? https://github.com/BernhardBaumrock/RockLESS/commit/c1738567b1d72aedd175d07a77fefb13d69ca99f 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 24, 2020 Author Share Posted March 24, 2020 v0.0.3 fixes a bug where cssUrl returned the path and not the relative url due to windows directory separator. Not sure why this was no issue until now... And another reason why I hope that we get $files->url() and $files->path() soon ? 1 Link to comment Share on other sites More sharing options...
bernhard Posted April 19, 2020 Author Share Posted April 19, 2020 v0.0.5 adds the link to the used parser to the readme and a parse() method to parse a string of less (not a less file) 1 Link to comment Share on other sites More sharing options...
gornycreative Posted April 23, 2020 Share Posted April 23, 2020 It looks like this module could allow for the introduction of field content prior to compiling - is that accurate? Is there anything special that needs to be done to prioritize it at runtime before ProCache? I'm looking to be able to push field values from SettingsFactory into the LESS file preproc. Link to comment Share on other sites More sharing options...
bernhard Posted April 23, 2020 Author Share Posted April 23, 2020 Yes, RockLESS can send variables from PHP to LESS: $less = $modules->get('RockLESS'); $less->vars = [ 'foo' => 'bar', ]; $css = $less->getCSS($config->paths->templates . 'less/theme.less')->cssUrl; echo "<link rel='stylesheet' type='text/css' href='$css'>"; How you combine that with ProCache is up to you. You can either send the compiled CSS to procache or I think you could also generate a LESS file via plain PHP listing your variables and include that file via @include in your LESS and then parse that LESS via ProCache. 1 Link to comment Share on other sites More sharing options...
bernhard Posted April 27, 2020 Author Share Posted April 27, 2020 Just added the feature to parse multiple LESS files into one single CSS (file or string), bumped the version to 1.0.0 and updated the readme (proper docs) ? 1 Link to comment Share on other sites More sharing options...
gornycreative Posted May 15, 2020 Share Posted May 15, 2020 This worked really nicely, but I have run into an interesting problem. I'm trying to use this in coordination with Settings Factory, and the issue I guess is that there is no real way for RockLESS to detect that the variables going into the CSS call have changed - so I can change the options all day long but the css won't regenrate because RockLess hasn't detected any changes in the less file it is calling - right? Would it make sense to hook the settings factory so that when the settings are saved the compiled file is deleted? Or would it be safer to just touch the less file the less file RockLess is trying to load? I'm curious if any others are trying to do something similar. Link to comment Share on other sites More sharing options...
bernhard Posted May 15, 2020 Author Share Posted May 15, 2020 5 hours ago, gornycreative said: Would it make sense to hook the settings factory so that when the settings are saved the compiled file is deleted? Yep. Perfect solution ? Link to comment Share on other sites More sharing options...
MarkE Posted August 2, 2020 Share Posted August 2, 2020 It appears that RockLESS uses LESS version 2.5.3. I am wanting 3.7 so that I can use the each() function. Is it possible to upgrade? Thanks. Link to comment Share on other sites More sharing options...
bernhard Posted August 2, 2020 Author Share Posted August 2, 2020 Hi @MarkE If you find any php less parsing library that supports it I'm happy to add support. it might be possible to add it. Link to comment Share on other sites More sharing options...
MarkE Posted August 2, 2020 Share Posted August 2, 2020 I'll take a look. Meanwhile, I'm doing a work-round to try and avoid needing each(). Thanks. Link to comment Share on other sites More sharing options...
gornycreative Posted May 29, 2021 Share Posted May 29, 2021 Does the new Less module added to core 179 replace this module? I currently use this to pull in settings factory variables as added values in LESS - if the same functionality exists in the new Less module then I'd like to refactor to just using one preprocessor. Link to comment Share on other sites More sharing options...
bernhard Posted May 29, 2021 Author Share Posted May 29, 2021 Not yet. Ryan asked me if we should use RockLess for the new admin theming feature but I voted against using RockLESS as it is more a proof of concept than a polished module. It lacks proper docs and some methods are redundant but slightly different. Ryans Less module is a simple wrapper around the same less parser that RockLESS uses but it lacks the file/directory monitoring part. I'd like to add that to ryans Less module one day for the same reason you are talking about, but I have no idea when that will happen. I thought it would be a good idea to start simple and solid with the new Less module and add features there when we need them. If you don't miss any features with Ryans module: Go with his module. If you miss features: Stay with RockLESS or even better make a PR so that we can shift to the new Less module ? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now