question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to skip arguments in fragments when using keyword arguments

See original GitHub issue

To Reproduce

Step by step instructions to reproduce the behavior:

Add to a page template:

{% fragment listNumbers(first, second, third=3, fourth=4) %}
  <p>{{ first }} {{ second }} {{ third }} {{ fourth }}</p>
{% endfragment %}

{% render listNumbers(1, 2) %}
{# Renders: `<p>1 2 3 4</p> #}

{% render listNumbers(1, third=9) %}
{# Renders: `<p>1  9 4</p> #}

Expected behavior

The rendered code should match the comments. Specifically, in the second example the “second” argument should be null. That is the behavior with Nunjucks macros.

Describe the bug

The missing second argument is passed an object of the keyword arguments instead:

{ third: 9, __keywords: true }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
abeacommented, May 19, 2021

Thanks for the reminder, @myovchev

0reactions
myovchevcommented, May 19, 2021

@abea The fix is merged so this could be closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I pass an argument to fragment using navigation ...
I am using SafeArgs and I only get this error when I define a default value for this argument. enter image description here....
Read more >
How to skip arguments when using a function - Julia Discourse
For positional arguments only the last parameters can have a default value, so say, you can't skip the second out of three arguments....
Read more >
Queries and Mutations - GraphQL
@skip(if: Boolean) Skip this field if the argument is true . Directives can be useful to get out of situations where you otherwise...
Read more >
Navigating with SafeArgs - Medium
SafeArgs is a gradle plugin that allows you to enter information into the navigation graph about the arguments that you want to pass....
Read more >
Testing tools - Django documentation
Test that a given request is rendered by a given Django template, with a template ... The values from the extra keyword arguments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found