libsass inspect,str_index

时间:2015-06-15 13:33:26

标签: sass gulp-sass libsass

我有以下代码在sass 3.4.14下运行良好

@function replaceAttribute($xml, $insert, $attribute) {
@if type-of($insert) != string {
    $insert: inspect($insert);
}
$search_str: $attribute + '="';

//How much to add to get to where the string should be inserted
$offset: str_length($search_str);
$idx: 1;
//The next attribute to replace in string
$next: str_index($xml, $search_str);

@while $next != null {
    $idx: $idx + $offset + $next - 1;

    //Remove old attribute value and add new
    $length_next: str_index(str_slice($xml, $idx), '"');
    $xml: str_slice($xml, 0, $idx - 1) + str_slice($xml, $idx + $length_next - 1);
    $xml: str_insert($xml, $insert, $idx);

    //Find new next attribute to replace
    $next: str_index(str_slice($xml, $idx), $search_str);
}
@return $xml;
}

使用libsass 3.2无效,但根据sass-compatibility.github.io/,应支持此处使用的所有字符串函数。 我收到以下错误消息:

$insert的{​​{1}}参数必须是字符串

我该如何解决这个问题?我正在尝试切换到libsass,因为编译时间很短。

0 个答案:

没有答案