asual/lesscss-engine — pull request #32 by rkrzewski (2012-08-08 20:42:25+00:00)
Title: Templating engine support - pluggable resource loading & resolution of includes in embedded styleshets

I've made some changes to improve integration of lesscss-engine with templating engines.

Number one requirement for integration is pluggable mechanism for locating and loading resources. I've created `ResourceLoade`r interface and made it available to engine.js through Rhino LiveConnect mechanism.

To preserve backwards compatibility, I've picked apart the resource loading behavior implemented in engine.js and re-implemented it as several composable `ResourceLoader` implementations. These can be used together to build a loader that behaves that the previous version of `engine.js` (which is positively validated by existing tests), rearranged, used in conjunction with user-provided implementations, or replaced altogether.

Another change that I've made is the possibility to pass a file location along with source string to compile method. If the source string is a stylesheet block extracted from a template, the location of the template file is necessary to resolve relative import paths. I've added a test case to verify this usage scenario. Location argument is optional. When not given, only absolute and schema - qualified imports are resolved - which is compatible with preexisting behavior.

I've taken care to preserve existing API and behavior, and refrain from gratuitous / stylistic changes.

I'd be happy to discuss these changes and work on them further if necessary.