mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
add unit function. Fixes #307
This commit is contained in:
@@ -209,6 +209,9 @@ tree.functions = {
|
||||
str = str.replace(/%%/g, '%');
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
unit: function (val, unit) {
|
||||
return new(tree.Dimension)(val.value, unit ? unit.toCSS() : "");
|
||||
},
|
||||
round: function (n, f) {
|
||||
var fraction = typeof(f) === "undefined" ? 0 : f.value;
|
||||
if (n instanceof tree.Dimension) {
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
format-multiple: "hello earth 2";
|
||||
format-url-encode: "red is %23ff0000";
|
||||
eformat: rgb(32, 128, 64);
|
||||
unitless: 12;
|
||||
unit: 14em;
|
||||
hue: 98;
|
||||
saturation: 12%;
|
||||
lightness: 95%;
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
format-multiple: %("hello %s %d", "earth", 2);
|
||||
format-url-encode: %('red is %A', #ff0000);
|
||||
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
|
||||
|
||||
unitless: unit(12px);
|
||||
unit: unit(13px + 1px, em);
|
||||
|
||||
hue: hue(hsl(98, 12%, 95%));
|
||||
saturation: saturation(hsl(98, 12%, 95%));
|
||||
|
||||
Reference in New Issue
Block a user