Have you noticed that you can now write the script using Coffeescript directly on the RUNJS, using less CSS to write the style.
Let's look at a demo code:
Coffeescript:
# Assignment:
Number = 42
opposite = True
# Conditions:
Number = -42 if opposite
# functions:
Square = (x)-> x * x
# Arrays:
list = [1, 2, 3, 4, 5]
# Objects:
Math =
Root:Math.sqrt
Square:square
Cube: (x)-> x * square x
# Splats:
Race = (Winner, runners ....) )->
Print winner, runners
# existence:
Alert "I knew it!" if Elvis?
# Array Comprehensions:
cubes = (math.cube num for num in list)
document.write "Result:" + cubes
Less:
@bgcolor: #CCC;
body{
Background-color: @bgcolor;
}
But runjs by default or by using JavaScript and CSS, how do I enable coffeescript and less CSS?
Enable Coffeescript
Move the mouse over the JavaScript panel and click JavaScript as shown in the following image:
After clicking, it will pop up the script selection dialog box, select Coffeescript and then determine:
The same way into the CSS editing panel click CSS to choose to write styles with less CSS:
Note notes:
Coffeescript, a programming language built on JavaScript, is compiled into efficient javascript so that you can run it on a Web browser or use it through a node.js class of technologies such as server-side applications. The compilation process is usually simple, and the resulting javascript is consistent with many of the best practices. Detailed Introduction
Less CSS is a wide range of CSS preprocessor, with simple syntax and variables to extend the CSS, can reduce the amount of code in the CSS. Detailed Introduction
Now go and experience the RUNJS that supports coffeescript and less CSS.
http://runjs.cn