Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using less-engine now

  • Loading branch information...
commit c3a0b10b8b83181d93fdba2f103b79fd15b22926 1 parent be3e694
@dansimpson authored
View
1  .gitignore
@@ -6,4 +6,5 @@ reports
.project
logs
*.classpath
+coffee-script.js
View
6 core/buildfile
@@ -3,9 +3,11 @@ require "buildr/scala"
Java.classpath << "src/resources"
repositories.remote << "http://repo1.maven.org/maven2/"
+repositories.remote << "http://www.asual.com/maven/content/groups/public"
GRIZZLED = "org.clapper:grizzled-scala_2.8.1:jar:1.0.4"
YUI = "com.yahoo.platform.yui:yuicompressor:jar:2.4.6"
+LESSENGINE = "com.asual.lesscss:lesscss-engine:jar:1.0.43"
desc "satchel - asset packaging for scala"
define "satchel" do
@@ -18,6 +20,6 @@ define "satchel" do
manifest["Copyright"] = "Dan Simpson (C) 2011"
manifest["Implementation-Vendor"] = "Dan Simpson"
- compile.with transitive(GRIZZLED), transitive(YUI)
- run.with transitive(GRIZZLED), transitive(YUI)
+ compile.with transitive(GRIZZLED), transitive(YUI), transitive(LESSENGINE)
+ run.with transitive(GRIZZLED), transitive(YUI), transitive(LESSENGINE)
end
View
14 core/src/main/scala/org/ds/satchel/processors/LessProcessor.scala
@@ -27,20 +27,14 @@
package org.ds.satchel.processors
import org.mozilla.javascript._
+import com.asual.lesscss._
class LessProcessor extends SatchelProcessor with RhinoSupport {
- val global = interpret("less.js")
-
+ val engine = new LessEngine()
+
override def process(content: String): String = {
- val context = Context.enter
- context.setLanguageVersion(Context.VERSION_1_5)
- val scope = context.newObject(global)
- scope.setParentScope(global)
- scope.put("source", scope, content)
- var result = context.evaluateString(scope, "compileString(source);", "less.js", 0, null).toString
- Context.exit
- result
+ engine.compile(content).replaceAll("\\\\n", "\n")
}
View
57 core/src/test/scala/org/ds/satchel/LessSpec.scala
@@ -1,28 +1,28 @@
/**
- ---------------------------------------------------------------------------
-
- Copyright (c) 2011 Dan Simpson
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-
- ---------------------------------------------------------------------------
- **/
+ * ---------------------------------------------------------------------------
+ *
+ * Copyright (c) 2011 Dan Simpson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * ---------------------------------------------------------------------------
+ */
package org.ds.satchel
@@ -32,6 +32,15 @@ import org.scalatest.matchers.ShouldMatchers
class LessSpec extends FlatSpec with ShouldMatchers {
"A less satchel" should "compile less into css" in {
+
+ val satchel = new Satchel(
+ name = "lessy",
+ root = "tests",
+ mime = "less",
+ compress = true,
+ patterns = List("test.less"))
+
+ satchel.processed should be("#header{color:#4d926f}")
}
}
View
4 core/tests/test.less
@@ -0,0 +1,4 @@
+@color: #4D926F;
+#header {
+ color: @color;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.