mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: Allow status-var to be quoted string or identifier
This commit is contained in:
parent
7890ec74ec
commit
f3886a77cf
@ -297,9 +297,13 @@ module.exports = function(str) {
|
||||
varName = buildIdentifier(varName, 'Invalid variable name');
|
||||
}
|
||||
|
||||
|
||||
if (statusVarName) {
|
||||
statusVarName = buildIdentifier(statusVarName, 'Invalid status-var option');
|
||||
statusVarName = compiler.builder.parseExpression(statusVarName);
|
||||
if (statusVarName.type === 'Literal') {
|
||||
statusVarName = compiler.builder.identifier(statusVarName.value);
|
||||
} else if (statusVarName.type !== 'Identifier') {
|
||||
throwError('Invalid status-var option');
|
||||
}
|
||||
}
|
||||
|
||||
if (forInit) {
|
||||
|
||||
1
test/fixtures/render/autotest/for-attr-status-var-string/expected.html
vendored
Normal file
1
test/fixtures/render/autotest/for-attr-status-var-string/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<div>red - true - false - 0 - 3</div>, <div>green - false - false - 1 - 3</div>, <div>blue - false - true - 2 - 3</div>
|
||||
3
test/fixtures/render/autotest/for-attr-status-var-string/template.marko
vendored
Normal file
3
test/fixtures/render/autotest/for-attr-status-var-string/template.marko
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<div for(item in ['red', 'green', 'blue'] | separator=', ' status-var="loop")>
|
||||
${item} - ${loop.isFirst()} - ${loop.isLast()} - ${loop.getIndex()} - ${loop.getLength()}
|
||||
</div>
|
||||
1
test/fixtures/render/autotest/for-attr-status-var-string/test.js
vendored
Normal file
1
test/fixtures/render/autotest/for-attr-status-var-string/test.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
exports.templateData = {};
|
||||
Loading…
x
Reference in New Issue
Block a user