Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple interface to modify variables and re-render CSS without reloading less-files session_cache value is stored at row 2784 Sample LESS: ------------ @bgcolor: black; @textcolor: yellow; body {background: @bgcolor; color: @textcolor;} From JS: -------- less.modifyVars({ '@bgcolor': 'blue', '@textcolor': 'red' });
- Loading branch information
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very useful. Any possibility to make this work with the newest version of less.js (1.3.0)?
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear christek,
Thank you for the positive comment :)
I have submitted a pull request a while ago.
The use-case for this is pretty narrow (IMHO) and that might be the reason to why it's down-prioritized.
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really, really useful. I think that if you do the changes in the source code of less.js instead of in the generated js you will have more chances to get the pull request approved.
You just need to modify lib/less/browser.js like this emiliosanchez@536b672
It works perfectly with 1.3.0
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi !
@emiliosanchez thank you for adding the modifyVars func to less lib, but how can I build or find a release from your modifications ?
Have a nice day !
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In https://github.com/emiliosanchez/less.js/tree/master/dist you have the files already builded. If you want to build by yourself you only have to invoke make from the main source directory (you will need nodejs)
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emiliosanchez thank you ! Very helpful
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks this is really awesome. Is there any way to commit to the new values to the .less file? As all the changes are lost on page reload
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear meelan,
My instant thought was that such feature isn't recommended and is outside the scope of this functionality.
Though after having thought about it, this can be useful and done with finess.
Nowadays, my problem is time; I prioritize private projects on my spare time. :-(
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! @emiliosanchez +1
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue was recently discovered and I've made a suggestion. If you use the function "modifyVars", I suggest that you follow this thread; less#721 (comment)
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the closest solution to easily allowing for dynamically updating variables based on WordPress Theme Options settings.
6508fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be awesome if the recompiling process wouldn't make chrome stutter, especially when modifying variables that are animating a height or something, it seems these seemingly basic animations don't run smoothly when less is still recompiling.