1 | /**
|
2 | * 字符截取
|
3 | *
|
4 | * @param {string} content 文本内容
|
5 | * @param {Object} attrs 属性
|
6 | * @param {string} attrs.begin 起始点
|
7 | * @param {string} attrs.end 结束点
|
8 | * @param {Object} scope 作用域
|
9 | * @param {Function} scope.execImport 导入数据
|
10 | */
|
11 | module.exports = function processor(content, attrs, scope) {
|
12 | if (!content) {
|
13 | return content;
|
14 | }
|
15 | var begin, end;
|
16 | if (attrs.begin) {
|
17 | begin = parseInt(scope.execImport(attrs.begin, ['argv', 'variant']), 10);
|
18 | }
|
19 | if (attrs.end) {
|
20 | end = parseInt(scope.execImport(attrs.end, ['argv', 'variant']), 10);
|
21 | }
|
22 | return content.slice(begin, end);
|
23 | }; |
\ | No newline at end of file |