I am getting a `parseSignature: expected comma after expression` when writing a custom tag

165 Views Asked by At

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?

0

There are 0 best solutions below