Railo running JAVA version of less.js

Jan 24 2012

Railo running JAVA version of less.js

Posted by AJ Mercer at 3:14 pm CFML | Railo

At Work, we are giving one of our sites a make over which was done by an external company. They have delivered some working HTML, but very quickly that I discovered that I am going to have to tweak the CSS - lots of hard coded height and widths for mega menu; not so good for a CMS.

After a bit of a look around it seems to me that it was generated with less.js. So I have asked if they could provide me with the less files.

While waiting for that I did a bit of Googling and found that Railo can run a JAVA version of less.js. A bit of downloading some JARS and cut and paste coding I had it working - first time!

Next I tweaked it a bit forther to create something that would output CSS content with something like:

<link rel='stylesheet' href='/less/index.cfm?src=/css/global-styles.less' />


<cfsetting enablecfoutputonly="true">
<cfparam name="URL.src" type="string">
<cfset variables.javajs = createObject("java","org.mozilla.javascript.tools.shell.Main",
<cfset variables.javaless = createObject("java","com.asual.lesscss.LessEngine",
<cfcontent type="text/css" reset="true">
<cfsetting enablecfoutputonly="false">

Thanks to Cfelement, Nathan Strutz and Asual - Oh, and those wonderful folks over at Railo ;-)


AJ Mercer

AJ Mercer wrote on 03/01/12 9:15 am

check out this project - looks really cool

David wrote on 03/01/12 1:03 pm

Why not just compile your code with Codekit or something ahead of time and then upload? Why the need for serverside Less?
AJ Mercer

AJ Mercer wrote on 04/11/12 1:26 pm

Sean Coyne has a Farcry Plugin

And it can compile Bootstrap 2 :-)