I am importing the following template from a Django project into a Storybook project to work on a design system.
{% slot "todo_text" default %}
Todo Item!
{% endslot %}
Nunjucks does not have a native slot tag so I am creating my own. I know the issue is because default is looked at as a second argument but it is not separated by a , so parseSignature() get angry.
Error: parseSignature: expected comma after expression
Below is the first part of my custom extension. I have copied until the part that triggers the error.
function SlotExtension() {
this.tags = ['slot'];
this.parse = function(parser, nodes, lexer) {
const token = parser.nextToken();
const args = parser.parseSignature(null, true); // fails here
}
}
Is there a way to force the parser to either ignore the default keyword or to treat a space as an argument separator?