lessCSS для MODX

lessCSS for MODX
Version: 1.3-pl
Created: May 12, 2012
Author: Darren Doyle <dd-modx@inv.email>
Site: http://inventurous.net

The lessCSS add-on for MODX allows you to use LESS files as if they were straight CSS—no need to compile and recompile locally, and, thanks to MODX's caching, no need for the server to continually recompile, either.

What is LESS? "LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions." Read more at the LESS CSS project website: http://lesscss.org/ If you are a web designer and you aren't using something like LESS or SASS, then you should be!

This plugin uses the lessphp compiler for LESS. http://leafo.net/lessphp/


* Create a new resource/document in MODX to serve as your main stylesheet.
* Be sure to give your new document a blank template
* Be sure to change the page type to CSS

* Add the lessCSS snippet to the content of your new page
* Set &path to the path to your LESS file *relative to base_url*
* Set &file to the name of your LESS file, include the extension
  - It is strongly recommended that you call the snippet cached! (more on that later)
  - The path variable will be prepended with MODX's base_url
  - End your path reference with a trailing slash /

  example: [[lessCSS? &path=`assets/templates/myTemplate/` &file=`style.less`]]

* Reference your file in your HTML header:

  example: <link rel="stylesheet" href="[[~123]]" />

It is best to use the snippet cached, i.e., without the no-cache flag (!). During development, uncheck the cacheable setting in the referencing document. Then, when done with development, turn the page caching back on to prevent lessphp from recompiling on every page load.

For some help for those getting started with LESS, a sample LESS setup for a site is included in the assets/components/lesscss/ folder.

&compress : yes/no : default = 1
  the add-on will strip unecessary white space from CSS output (renders CSS largely unreadable)

&fixRelativePaths : yes/no : default = 1
  the add-on will fix relative URLs in the output to point to the path set in the &path option. This allows you to use paths in your LESS file relative to the LESS file without regard to the path of the MODX output. Will not affect any paths that start with 'http://', 'https://', or '/'.