-
Notifications
You must be signed in to change notification settings - Fork 2
ArgToken (EN)
bhsd edited this page Jan 3, 2024
·
11 revisions
Template arguments wrapped in {{{}}}
.
✅ Available in the Mini and Browser versions.
✅ Expand
type: string | false
Default value.
// default
var {firstChild} = Parser.parse('{{{a}}}');
assert.equal(firstChild, '{{{a}}}');
assert.strictEqual(firstChild.default, false);
firstChild.default = 'b';
assert.equal(firstChild, '{{{a|b}}}');
Expand
type: string
Name of the argument, read-only.
// name
var {firstChild} = Parser.parse('{{{a}}}');
assert.equal(firstChild, '{{{a}}}');
assert.strictEqual(firstChild.name, 'a');
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var noinclude = Parser.parse('{{{a}}}').firstChild;
assert.equal(noinclude, '{{{a}}}');
assert.deepEqual(noinclude.lint(), [
{
severity: 'error',
message: 'unexpected template argument',
startLine: 0,
startCol: 0,
startIndex: 0,
endLine: 0,
endCol: 7,
endIndex: 7,
excerpt: '{{{a}}}',
},
]);
var include = Parser.parse('{{{a|b|c}}}', true).firstChild;
assert.equal(include, '{{{a|b|c}}}');
assert.deepEqual(include.lint(), [
{
severity: 'error',
message: 'invisible content inside triple braces',
startLine: 0,
startCol: 6,
startIndex: 6,
endLine: 0,
endCol: 8,
endIndex: 8,
excerpt: '|c',
},
]);
Expand
returns: this
Deep clone the node.
// cloneNode
var {firstChild} = Parser.parse('{{{a}}}');
assert.equal(firstChild, '{{{a}}}');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
Expand
Remove redundant parts.
// removeRedundant
var {firstChild} = Parser.parse('{{{a|b|c}}}');
assert.equal(firstChild, '{{{a|b|c}}}');
firstChild.removeRedundant();
assert.equal(firstChild, '{{{a|b}}}');
Expand
param: string
new argument name
Set the argument name.
// setName
var {firstChild} = Parser.parse('{{{a}}}');
assert.equal(firstChild, '{{{a}}}');
firstChild.setName('b');
assert.equal(firstChild, '{{{b}}}');
Expand
param: string
Set the default value.
// setDefault
var {firstChild} = Parser.parse('{{{a}}}');
assert.equal(firstChild, '{{{a}}}');
firstChild.setDefault('b');
assert.equal(firstChild, '{{{a|b}}}');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext