Jump to content

Recommended Posts

  • 1 year later...
Posted

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.

  • 1 month later...
Posted

@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.

Posted

@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.

Posted

@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!

  • 2 weeks later...
Posted

@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.

  • Thanks 1
Posted

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 ? 

  • Like 1
  • 4 weeks later...
Posted

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)

  • Like 1
Posted

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.

Posted

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.

  • Like 1
Posted

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) ?

  • Like 1
  • 3 weeks later...
Posted

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.

Posted
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 ? 

  • 2 months later...
Posted

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.

  • 9 months later...
Posted

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.

Posted

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 ? 

  • Like 2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...