我想创建一个mixin,通过合并其参数来返回命名空间变量的值。
见:
@namespace_thing: "some value";
@namespace_otherthing: "some other value";
@othernamespace_thing: "another value";
@othernamespace_otherthing: "again other value";
mixin:
.monster(@namespace,@var){
@tmp: ~"@{namespace}"+"_"+@{var};
content: @tmp // That's what I just dont know.
}
#TESTSELECTOR{
.monster(namespace,thing); // would return
content: "some value";
}
答案 0 :(得分:2)
最简单的方法是使用variable name references:
@namespace_thing: "some value";
.monster(@namespace, @var) {
@ref: '@{namespace}_@{var}';
content: @@ref;
}
usage {
.monster(namespace, thing);
}
如果您需要返回值而不是将其分配给预定义的属性,请参阅mixins as functions。