如何创建手写笔EMPTY文本变量?
$cross(prop)
prop = shift(arguments)
-webkit-{prop} arguments
-moz-{prop} arguments
-ms-{prop} arguments
-o-{prop} arguments
{prop} arguments
$transition()
attrs = shift(arguments)
if length(arguments)
str = ????WTF???
for arg in arguments
if length(str)
str += \,
str += arg attrs
$cross (transition) (str)
我想创建转换mixin:
$transition((.4s ease out), opacity, visibility)
答案 0 :(得分:1)
不幸的是,length
bif只能用于列表/哈希。它总是为其他节点返回1
。你可以写下这样的东西:
$transition()
attrs = shift(arguments)
if length(arguments)
str = ''
for arg in arguments
if str != ''
str += ', '
str += arg, attrs
$cross (transition) unquote(str) // unquote to remove quotes
或者您可以编写自定义函数来获取字符串长度:
str-length.js
module.exports = function() {
return function(stylus) {
stylus.define('str-length', function(str) {
return str.val.length;
});
};
};
test.styl
use('str-length.js')
$cross(prop)
prop = shift(arguments)
-webkit-{prop} arguments
-moz-{prop} arguments
-ms-{prop} arguments
-o-{prop} arguments
{prop} arguments
$transition()
attrs = shift(arguments)
if length(arguments)
str = ''
for arg in arguments
if str-length(str)
str += ', '
str += arg attrs
$cross (transition) unquote(str) // unquote to remove quotes
body
$transition((.4s ease out), opacity, visibility)