less 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/less.gemspec +1 -1
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/v8_context.rb +1 -1
- data/lib/less/js/.gitattributes +3 -2
- data/lib/less/js/.gitignore +18 -2
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/CHANGELOG.md +87 -2
- data/lib/less/js/CONTRIBUTING.md +4 -3
- data/lib/less/js/Gruntfile.js +290 -0
- data/lib/less/js/README.md +342 -12
- data/lib/less/js/benchmark/benchmark.less +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +154 -12
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/build/README.md +350 -0
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +160 -0
- data/lib/less/js/build/require-rhino.js +7 -2
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +482 -367
- data/lib/less/js/lib/less/colors.js +0 -1
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +50 -19
- data/lib/less/js/lib/less/extend-visitor.js +66 -41
- data/lib/less/js/lib/less/functions.js +309 -104
- data/lib/less/js/lib/less/import-visitor.js +21 -10
- data/lib/less/js/lib/less/index.js +90 -68
- data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
- data/lib/less/js/lib/less/lessc_helper.js +56 -45
- data/lib/less/js/lib/less/parser.js +830 -460
- data/lib/less/js/lib/less/rhino.js +380 -58
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +215 -0
- data/lib/less/js/lib/less/tree.js +57 -5
- data/lib/less/js/lib/less/tree/alpha.js +13 -5
- data/lib/less/js/lib/less/tree/anonymous.js +11 -5
- data/lib/less/js/lib/less/tree/assignment.js +11 -5
- data/lib/less/js/lib/less/tree/call.js +19 -8
- data/lib/less/js/lib/less/tree/color.js +59 -36
- data/lib/less/js/lib/less/tree/comment.js +17 -4
- data/lib/less/js/lib/less/tree/condition.js +3 -3
- data/lib/less/js/lib/less/tree/dimension.js +161 -153
- data/lib/less/js/lib/less/tree/directive.js +39 -18
- data/lib/less/js/lib/less/tree/element.js +41 -18
- data/lib/less/js/lib/less/tree/expression.js +11 -5
- data/lib/less/js/lib/less/tree/extend.js +11 -1
- data/lib/less/js/lib/less/tree/import.js +34 -20
- data/lib/less/js/lib/less/tree/javascript.js +16 -10
- data/lib/less/js/lib/less/tree/keyword.js +5 -2
- data/lib/less/js/lib/less/tree/media.js +39 -22
- data/lib/less/js/lib/less/tree/mixin.js +135 -56
- data/lib/less/js/lib/less/tree/negative.js +4 -2
- data/lib/less/js/lib/less/tree/operation.js +17 -12
- data/lib/less/js/lib/less/tree/paren.js +5 -2
- data/lib/less/js/lib/less/tree/quoted.js +9 -6
- data/lib/less/js/lib/less/tree/rule.js +39 -21
- data/lib/less/js/lib/less/tree/ruleset.js +229 -145
- data/lib/less/js/lib/less/tree/selector.js +101 -34
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
- data/lib/less/js/lib/less/tree/url.js +33 -11
- data/lib/less/js/lib/less/tree/value.js +13 -6
- data/lib/less/js/lib/less/tree/variable.js +13 -8
- data/lib/less/js/lib/less/visitor.js +117 -25
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +30 -15
- data/lib/less/js/test/browser/common.js +131 -56
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +8 -9
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
- data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
- data/lib/less/js/test/browser/css/urls.css +18 -14
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
- data/lib/less/js/test/browser/less/urls.less +9 -1
- data/lib/less/js/test/browser/phantom-runner.js +112 -103
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/{runner-legacy.js → runner-legacy-spec.js} +1 -4
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/{runner-rootpath-relative.js → runner-rootpath-relative-spec.js} +1 -3
- data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/colors.css +7 -0
- data/lib/less/js/test/css/comments.css +9 -4
- data/lib/less/js/test/css/compression/compression.css +3 -2
- data/lib/less/js/test/css/css-3.css +17 -5
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +9 -0
- data/lib/less/js/test/css/extend-selector.css +10 -2
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +23 -10
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-once.css +12 -0
- data/lib/less/js/test/css/import-reference.css +49 -0
- data/lib/less/js/test/css/import.css +0 -2
- data/lib/less/js/test/css/media.css +21 -5
- data/lib/less/js/test/css/merge.css +26 -0
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +6 -0
- data/lib/less/js/test/css/mixins-important.css +7 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins.css +20 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/parens.css +3 -0
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/selectors.css +12 -0
- data/lib/less/js/test/css/static-urls/urls.css +7 -4
- data/lib/less/js/test/css/strings.css +3 -0
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +21 -9
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less-test.js +234 -191
- data/lib/less/js/test/less/colors.less +6 -0
- data/lib/less/js/test/less/comments.less +7 -1
- data/lib/less/js/test/less/compression/compression.less +21 -1
- data/lib/less/js/test/less/css-3.less +12 -0
- data/lib/less/js/test/less/css-guards.less +99 -0
- data/lib/less/js/test/less/debug/linenumbers.less +11 -1
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -2
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -1
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -2
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +12 -0
- data/lib/less/js/test/less/extend-selector.less +15 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +15 -2
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-once.less +2 -0
- data/lib/less/js/test/less/import-reference.less +18 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
- data/lib/less/js/test/less/import/import-reference.less +43 -0
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/media.less +25 -1
- data/lib/less/js/test/less/merge.less +59 -0
- data/lib/less/js/test/less/mixins-args.less +10 -0
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +16 -0
- data/lib/less/js/test/less/mixins-important.less +4 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins.less +27 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/parens.less +4 -0
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/selectors.less +13 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/strings.less +6 -0
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +15 -0
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +48 -40
- data/lib/less/version.rb +1 -1
- data/spec/less/parser_spec.rb +15 -15
- metadata +146 -40
- data/lib/less/js/Makefile +0 -102
- data/lib/less/js/build/header.js +0 -9
- data/lib/less/js/test/browser-test-prepare.js +0 -46
- data/lib/less/js/test/browser/runner-errors.js +0 -5
- data/lib/less/js/test/browser/runner-main.js +0 -15
- data/lib/less/js/test/browser/template.htm +0 -10
- data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# [Less.js v<%= pkg.version %>](http://lesscss.org)
|
|
2
|
+
|
|
3
|
+
> The **dynamic** stylesheet language. [http://lesscss.org](http://lesscss.org).
|
|
4
|
+
|
|
5
|
+
This is the JavaScript, and now official, stable version of LESS.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Getting Started
|
|
9
|
+
|
|
10
|
+
Options for adding Less.js to your project:
|
|
11
|
+
|
|
12
|
+
* Install with [NPM](https://npmjs.org/): `npm install less`
|
|
13
|
+
* [Download the latest release][download]
|
|
14
|
+
* Clone the repo: `git clone git://github.com/less/less.js.git`
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Feature Highlights
|
|
19
|
+
LESS extends CSS with dynamic features such as:
|
|
20
|
+
|
|
21
|
+
* [nesting](#nesting)
|
|
22
|
+
* [variables](#variables)
|
|
23
|
+
* [operations](#operations)
|
|
24
|
+
* [mixins](#mixins)
|
|
25
|
+
* [extend](#extend) (selector inheritance)
|
|
26
|
+
|
|
27
|
+
To learn about the many other features Less.js has to offer please visit [http://lesscss.org](http://lesscss.org) and [the Less.js wiki][wiki]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Examples
|
|
31
|
+
#### nesting
|
|
32
|
+
Take advantage of nesting to make code more readable and maintainable. This:
|
|
33
|
+
|
|
34
|
+
```less
|
|
35
|
+
.nav > li > a {
|
|
36
|
+
border: 1px solid #f5f5f5;
|
|
37
|
+
&:hover {
|
|
38
|
+
border-color: #ddd;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
renders to:
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
.nav > li > a {
|
|
47
|
+
border: 1px solid #f5f5f5;
|
|
48
|
+
}
|
|
49
|
+
.nav > li > a:hover {
|
|
50
|
+
border-color: #ddd;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#### variables
|
|
56
|
+
Updated commonly used values from a single location.
|
|
57
|
+
|
|
58
|
+
```less
|
|
59
|
+
// Variables ("inline" comments like this can be used)
|
|
60
|
+
@link-color: #428bca; // appears as "sea blue"
|
|
61
|
+
|
|
62
|
+
/* Or "block comments" that span
|
|
63
|
+
multiple lines, like this */
|
|
64
|
+
a {
|
|
65
|
+
color: @link-color; // use the variable in styles
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Variables can also be used in `@import` statements, URLs, selector names, and more.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
#### operations
|
|
74
|
+
Continuing with the same example above, we can use our variables even easier to maintain with _operations_, which enables the use of addition, subraction, multiplication and division in your styles:
|
|
75
|
+
|
|
76
|
+
```less
|
|
77
|
+
// Variables
|
|
78
|
+
@link-color: #428bca;
|
|
79
|
+
@link-color-hover: darken(@link-color, 10%);
|
|
80
|
+
|
|
81
|
+
// Styles
|
|
82
|
+
a {
|
|
83
|
+
color: @link-color;
|
|
84
|
+
}
|
|
85
|
+
a:hover {
|
|
86
|
+
color: @link-color-hover;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
renders to:
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
a {
|
|
93
|
+
color: #428bca;
|
|
94
|
+
}
|
|
95
|
+
a:hover {
|
|
96
|
+
color: #3071a9;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### mixins
|
|
101
|
+
##### "implicit" mixins
|
|
102
|
+
Mixins enable you to apply the styles of one selector inside another selector like this:
|
|
103
|
+
|
|
104
|
+
```less
|
|
105
|
+
// Variables
|
|
106
|
+
@link-color: #428bca;
|
|
107
|
+
|
|
108
|
+
// Any "regular" class...
|
|
109
|
+
.link {
|
|
110
|
+
color: @link-color;
|
|
111
|
+
}
|
|
112
|
+
a {
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
.link; // ...can be used as an "implicit" mixin
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
renders to:
|
|
119
|
+
|
|
120
|
+
```css
|
|
121
|
+
.link {
|
|
122
|
+
color: #428bca;
|
|
123
|
+
}
|
|
124
|
+
a {
|
|
125
|
+
font-weight: bold;
|
|
126
|
+
color: #428bca;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
So any selector can be an "implicit mixin". We'll show you a DRYer way to do this below.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
##### parametric mixins
|
|
135
|
+
Mixins can also accept parameters:
|
|
136
|
+
|
|
137
|
+
```less
|
|
138
|
+
// Transition mixin
|
|
139
|
+
.transition(@transition) {
|
|
140
|
+
-webkit-transition: @transition;
|
|
141
|
+
-moz-transition: @transition;
|
|
142
|
+
-o-transition: @transition;
|
|
143
|
+
transition: @transition;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
used like this:
|
|
148
|
+
|
|
149
|
+
```less
|
|
150
|
+
// Variables
|
|
151
|
+
@link-color: #428bca;
|
|
152
|
+
@link-color-hover: darken(@link-color, 10%);
|
|
153
|
+
|
|
154
|
+
//Transition mixin would be anywhere here
|
|
155
|
+
|
|
156
|
+
a {
|
|
157
|
+
font-weight: bold;
|
|
158
|
+
color: @link-color;
|
|
159
|
+
.transition(color .2s ease-in-out);
|
|
160
|
+
// Hover state
|
|
161
|
+
&:hover {
|
|
162
|
+
color: @link-color-hover;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
renders to:
|
|
168
|
+
|
|
169
|
+
```css
|
|
170
|
+
a {
|
|
171
|
+
font-weight: bold;
|
|
172
|
+
color: #428bca;
|
|
173
|
+
-webkit-transition: color 0.2s ease-in-out;
|
|
174
|
+
-moz-transition: color 0.2s ease-in-out;
|
|
175
|
+
-o-transition: color 0.2s ease-in-out;
|
|
176
|
+
transition: color 0.2s ease-in-out;
|
|
177
|
+
}
|
|
178
|
+
a:hover {
|
|
179
|
+
color: #3071a9;
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
#### extend
|
|
185
|
+
The `extend` feature can be thought of as the _inverse_ of mixins. It accomplishes the goal of "borrowing styles", but rather than copying all the rules of _Selector A_ over to _Selector B_, `extend` copies the name of the _inheriting selector_ (_Selector B_) over to the _extending selector_ (_Selector A_). So continuing with the example used for [mixins](#mixins) above, extend works like this:
|
|
186
|
+
|
|
187
|
+
```less
|
|
188
|
+
// Variables
|
|
189
|
+
@link-color: #428bca;
|
|
190
|
+
|
|
191
|
+
.link {
|
|
192
|
+
color: @link-color;
|
|
193
|
+
}
|
|
194
|
+
a:extend(.link) {
|
|
195
|
+
font-weight: bold;
|
|
196
|
+
}
|
|
197
|
+
// Can also be written as
|
|
198
|
+
a {
|
|
199
|
+
&:extend(.link);
|
|
200
|
+
font-weight: bold;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
renders to:
|
|
205
|
+
|
|
206
|
+
```css
|
|
207
|
+
.link, a {
|
|
208
|
+
color: #428bca;
|
|
209
|
+
}
|
|
210
|
+
a {
|
|
211
|
+
font-weight: bold;
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Usage
|
|
216
|
+
|
|
217
|
+
### Compiling and Parsing
|
|
218
|
+
Invoke the compiler from node:
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
var less = require('less');
|
|
222
|
+
|
|
223
|
+
less.render('.class { width: (1 + 1) }', function (e, css) {
|
|
224
|
+
console.log(css);
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Outputs:
|
|
229
|
+
|
|
230
|
+
```css
|
|
231
|
+
.class {
|
|
232
|
+
width: 2;
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
You may also manually invoke the parser and compiler:
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
var parser = new(less.Parser);
|
|
240
|
+
|
|
241
|
+
parser.parse('.class { width: (1 + 1) }', function (err, tree) {
|
|
242
|
+
if (err) { return console.error(err) }
|
|
243
|
+
console.log(tree.toCSS());
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
### Configuration
|
|
249
|
+
You may also pass options to the compiler:
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
var parser = new(less.Parser)({
|
|
253
|
+
paths: ['.', './src/less'], // Specify search paths for @import directives
|
|
254
|
+
filename: 'style.less' // Specify a filename, for better error messages
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
parser.parse('.class { width: (1 + 1) }', function (e, tree) {
|
|
258
|
+
tree.toCSS({ compress: true }); // Minify CSS output
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## More information
|
|
263
|
+
|
|
264
|
+
For general information on the language, configuration options or usage visit [lesscss.org](http://lesscss.org) or [the less wiki][wiki].
|
|
265
|
+
|
|
266
|
+
Here are other resources for using Less.js:
|
|
267
|
+
|
|
268
|
+
* [stackoverflow.com][so] is a great place to get answers about Less.
|
|
269
|
+
* [node.js tools](https://github.com/less/less.js/wiki/Converting-LESS-to-CSS) for converting Less to CSS
|
|
270
|
+
* [GUI compilers for Less](https://github.com/less/less.js/wiki/GUI-compilers-that-use-LESS.js)
|
|
271
|
+
* [Less.js Issues][issues] for reporting bugs
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
## Contributing
|
|
276
|
+
Please read [CONTRIBUTING.md](./CONTRIBUTING.md). Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
|
|
277
|
+
|
|
278
|
+
### Reporting Issues
|
|
279
|
+
|
|
280
|
+
Before opening any issue, please search for existing issues and read the [Issue Guidelines](https://github.com/necolas/issue-guidelines), written by [Nicolas Gallagher](https://github.com/necolas/). After that if you find a bug or would like to make feature request, [please open a new issue][issues].
|
|
281
|
+
|
|
282
|
+
Please report documentation issues in [the documentation project](https://github.com/less/less-docs).
|
|
283
|
+
|
|
284
|
+
### Development
|
|
285
|
+
|
|
286
|
+
#### Install Less.js
|
|
287
|
+
|
|
288
|
+
Start by either [downloading this project][download] manually, or in the command line:
|
|
289
|
+
|
|
290
|
+
```shell
|
|
291
|
+
git clone https://github.com/less/less.js.git "less"
|
|
292
|
+
```
|
|
293
|
+
and then `cd less`.
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
#### Install dependencies
|
|
297
|
+
|
|
298
|
+
To install all the dependencies for less development, run:
|
|
299
|
+
|
|
300
|
+
```shell
|
|
301
|
+
npm install
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
If you haven't run grunt before, install grunt-cli globally so you can just run `grunt`
|
|
305
|
+
|
|
306
|
+
```shell
|
|
307
|
+
npm install grunt-cli -g
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
You should now be able to build Less.js, run tests, benchmarking, and other tasks listed in the Gruntfile.
|
|
311
|
+
|
|
312
|
+
## Using Less.js Grunt
|
|
313
|
+
|
|
314
|
+
Tests, benchmarking and building is done using Grunt `<%= pkg.devDependencies.grunt %>`. If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to install and use Grunt plugins, which are necessary for development with Less.js.
|
|
315
|
+
|
|
316
|
+
The Less.js [Gruntfile](Gruntfile.js) is configured with the following "convenience tasks" :
|
|
317
|
+
|
|
318
|
+
#### test - `grunt`
|
|
319
|
+
Runs jshint, nodeunit and headless jasmine tests using [phantomjs](http://code.google.com/p/phantomjs/). You must have phantomjs installed for the jasmine tests to run.
|
|
320
|
+
|
|
321
|
+
#### test - `grunt benchmark`
|
|
322
|
+
Runs the benchmark suite.
|
|
323
|
+
|
|
324
|
+
#### build for testing browser - 'grunt browser'
|
|
325
|
+
This builds less.js and puts it in 'test/browser/less.js'
|
|
326
|
+
|
|
327
|
+
#### build - `grunt stable | grunt beta | grunt alpha`
|
|
328
|
+
Builds Less.js from from the `/lib/less` source files. This is done by the developer releasing a new release, do not do this if you are creating a pull request.
|
|
329
|
+
|
|
330
|
+
#### readme - `grunt readme`
|
|
331
|
+
Build the README file from [a template](build/README.md) to ensure that metadata is up-to-date and (more likely to be) correct.
|
|
332
|
+
|
|
333
|
+
Please review the [Gruntfile](Gruntfile.js) to become acquainted with the other available tasks.
|
|
334
|
+
|
|
335
|
+
**Please note** that if you have any issues installing dependencies or running any of the Gruntfile commands, please make sure to uninstall any previous versions, both in the local node_modules directory, and clear your global npm cache, and then try running `npm install` again. After that if you still have issues, please let us know about it so we can help.
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
## Release History
|
|
339
|
+
See the [changelog](CHANGELOG.md)
|
|
340
|
+
|
|
341
|
+
## [License](LICENSE)
|
|
342
|
+
|
|
343
|
+
Copyright (c) 2009-<%= grunt.template.today("yyyy") %> [Alexis Sellier](http://cloudhead.io/) & The Core Less Team
|
|
344
|
+
Licensed under the [Apache License](LICENSE).
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
[so]: http://stackoverflow.com/questions/tagged/twitter-bootstrap+less "StackOverflow.com"
|
|
348
|
+
[issues]: https://github.com/less/less.js/issues "GitHub Issues for Less.js"
|
|
349
|
+
[wiki]: https://github.com/less/less.js/wiki "The official wiki for Less.js"
|
|
350
|
+
[download]: https://github.com/less/less.js/zipball/master "Download Less.js"
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
###
|
|
2
|
+
# NOTICE:
|
|
3
|
+
# this file is specifically for controlling
|
|
4
|
+
# paths for Less.js source files, as well as
|
|
5
|
+
# the order in which source files are
|
|
6
|
+
# concatenated.
|
|
7
|
+
#
|
|
8
|
+
# Please do not add paths for anything else
|
|
9
|
+
# to this file. All other paths for testing,
|
|
10
|
+
# benchmarking and so on should be controlled
|
|
11
|
+
# in the Gruntfile.
|
|
12
|
+
###
|
|
13
|
+
|
|
14
|
+
# Less.js Lib
|
|
15
|
+
lib: lib/less
|
|
16
|
+
lib_source_map: 'lib/source-map'
|
|
17
|
+
|
|
18
|
+
# =================================
|
|
19
|
+
# General
|
|
20
|
+
# =================================
|
|
21
|
+
prepend:
|
|
22
|
+
browser: ['build/require.js', 'build/browser-header.js']
|
|
23
|
+
rhino: ['build/require-rhino.js', 'build/rhino-header.js', 'build/rhino-modules.js']
|
|
24
|
+
|
|
25
|
+
append:
|
|
26
|
+
amd: build/amd.js
|
|
27
|
+
browser: <%= build.lib %>/browser.js
|
|
28
|
+
rhino: <%= build.lib %>/rhino.js
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# =================================
|
|
32
|
+
# Core less files
|
|
33
|
+
# =================================
|
|
34
|
+
|
|
35
|
+
# <%= build.less.* %>
|
|
36
|
+
less:
|
|
37
|
+
parser : <%= build.lib %>/parser.js
|
|
38
|
+
functions : <%= build.lib %>/functions.js
|
|
39
|
+
colors : <%= build.lib %>/colors.js
|
|
40
|
+
tree : <%= build.lib %>/tree.js
|
|
41
|
+
treedir : <%= build.lib %>/tree/*.js # glob all files in ./lib/less/tree directory
|
|
42
|
+
env : <%= build.lib %>/env.js
|
|
43
|
+
visitor : <%= build.lib %>/visitor.js
|
|
44
|
+
import_visitor : <%= build.lib %>/import-visitor.js
|
|
45
|
+
join : <%= build.lib %>/join-selector-visitor.js
|
|
46
|
+
to_css_visitor : <%= build.lib %>/to-css-visitor.js
|
|
47
|
+
extend_visitor : <%= build.lib %>/extend-visitor.js
|
|
48
|
+
browser : <%= build.lib %>/browser.js
|
|
49
|
+
source_map_output: <%= build.lib %>/source-map-output.js
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# =================================
|
|
53
|
+
# Browser build
|
|
54
|
+
# =================================
|
|
55
|
+
|
|
56
|
+
# <%= build.browser %>
|
|
57
|
+
browser:
|
|
58
|
+
|
|
59
|
+
# prepend utils
|
|
60
|
+
- <%= build.prepend.browser %>
|
|
61
|
+
|
|
62
|
+
# core
|
|
63
|
+
- <%= build.less.parser %>
|
|
64
|
+
- <%= build.less.functions %>
|
|
65
|
+
- <%= build.less.colors %>
|
|
66
|
+
- <%= build.less.tree %>
|
|
67
|
+
- <%= build.less.treedir %> # glob all files
|
|
68
|
+
- <%= build.less.env %>
|
|
69
|
+
- <%= build.less.visitor %>
|
|
70
|
+
- <%= build.less.import_visitor %>
|
|
71
|
+
- <%= build.less.join %>
|
|
72
|
+
- <%= build.less.to_css_visitor %>
|
|
73
|
+
- <%= build.less.extend_visitor %>
|
|
74
|
+
- <%= build.less.source_map_output %>
|
|
75
|
+
|
|
76
|
+
# append browser-specific code
|
|
77
|
+
- <%= build.append.browser %>
|
|
78
|
+
- <%= build.append.amd %>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# =================================
|
|
82
|
+
# Rhino build
|
|
83
|
+
# =================================
|
|
84
|
+
|
|
85
|
+
# <%= build.rhino %>
|
|
86
|
+
rhino:
|
|
87
|
+
# prepend utils
|
|
88
|
+
- <%= build.prepend.rhino %>
|
|
89
|
+
|
|
90
|
+
# core
|
|
91
|
+
- <%= build.less.parser %>
|
|
92
|
+
- <%= build.less.functions %>
|
|
93
|
+
- <%= build.less.colors %>
|
|
94
|
+
- <%= build.less.tree %>
|
|
95
|
+
- <%= build.less.treedir %> # glob all files
|
|
96
|
+
- <%= build.less.env %>
|
|
97
|
+
- <%= build.less.visitor %>
|
|
98
|
+
- <%= build.less.import_visitor %>
|
|
99
|
+
- <%= build.less.join %>
|
|
100
|
+
- <%= build.less.to_css_visitor %>
|
|
101
|
+
- <%= build.less.extend_visitor %>
|
|
102
|
+
- <%= build.less.source_map_output %>
|
|
103
|
+
- <%= build.source_map %>
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# <%= build.rhinolessc %>
|
|
107
|
+
rhinolessc:
|
|
108
|
+
- <%= build.append.rhino %>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# =================================
|
|
112
|
+
# Tree files
|
|
113
|
+
# =================================
|
|
114
|
+
|
|
115
|
+
# <%= build.tree %>
|
|
116
|
+
# Technically listing the array out this way isn't
|
|
117
|
+
# necessary since we can glob the files in alphabetical
|
|
118
|
+
# order anyway. But this gives you control over the order
|
|
119
|
+
# the files are used, and allows targeting of individual
|
|
120
|
+
# files directly in the Gruntfile. But be we can just
|
|
121
|
+
# remove this if files can be concatenated in any order.
|
|
122
|
+
tree:
|
|
123
|
+
- <%= build.lib %>/tree/alpha.js
|
|
124
|
+
- <%= build.lib %>/tree/anonymous.js
|
|
125
|
+
- <%= build.lib %>/tree/assignment.js
|
|
126
|
+
- <%= build.lib %>/tree/call.js
|
|
127
|
+
- <%= build.lib %>/tree/color.js
|
|
128
|
+
- <%= build.lib %>/tree/comment.js
|
|
129
|
+
- <%= build.lib %>/tree/condition.js
|
|
130
|
+
- <%= build.lib %>/tree/dimension.js
|
|
131
|
+
- <%= build.lib %>/tree/directive.js
|
|
132
|
+
- <%= build.lib %>/tree/element.js
|
|
133
|
+
- <%= build.lib %>/tree/expression.js
|
|
134
|
+
- <%= build.lib %>/tree/extend.js
|
|
135
|
+
- <%= build.lib %>/tree/import.js
|
|
136
|
+
- <%= build.lib %>/tree/javascript.js
|
|
137
|
+
- <%= build.lib %>/tree/keyword.js
|
|
138
|
+
- <%= build.lib %>/tree/media.js
|
|
139
|
+
- <%= build.lib %>/tree/mixin.js
|
|
140
|
+
- <%= build.lib %>/tree/negative.js
|
|
141
|
+
- <%= build.lib %>/tree/operation.js
|
|
142
|
+
- <%= build.lib %>/tree/paren.js
|
|
143
|
+
- <%= build.lib %>/tree/quoted.js
|
|
144
|
+
- <%= build.lib %>/tree/rule.js
|
|
145
|
+
- <%= build.lib %>/tree/ruleset.js
|
|
146
|
+
- <%= build.lib %>/tree/selector.js
|
|
147
|
+
- <%= build.lib %>/tree/unicode-descriptor.js
|
|
148
|
+
- <%= build.lib %>/tree/url.js
|
|
149
|
+
- <%= build.lib %>/tree/value.js
|
|
150
|
+
- <%= build.lib %>/tree/variable.js
|
|
151
|
+
|
|
152
|
+
# =================================
|
|
153
|
+
# source-map build
|
|
154
|
+
# =================================
|
|
155
|
+
|
|
156
|
+
# <%= build.source_map %>
|
|
157
|
+
source_map:
|
|
158
|
+
- <%= build.lib_source_map %>/source-map-header.js
|
|
159
|
+
- <%= build.lib_source_map %>/source-map-0.1.31.js
|
|
160
|
+
- <%= build.lib_source_map %>/source-map-footer.js
|