-
-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't know where shortcode fails in Nunjucks template #3330
Comments
This is most likely an issue of how your code interfaces with Your issue stems from this error message:
Be sure that you're passing something as Also for future reference, issues regarding |
|
I moved this to 11ty/eleventy-img but I immediately changed my mind. Gonna move this one back to core. |
I think there’s something here, for sure. Throwing an error in a shortcode should report where in the template it came from. |
This was fixed by #3286! Here’s what it looks like starting with 3.0.0-alpha.15: [11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./contentfile.njk (via TemplateContentRenderError)
[11ty] 2. (./contentfile.njk)
[11ty] EleventyShortcodeError: Error with Nunjucks shortcode `test` (via Template render error)
[11ty] 3. NO! (via Template render error)
[11ty]
[11ty] Original error stack trace: Error: NO!
[11ty] at Object.<anonymous> (file:///Users/zachleat/Temp/eleventy-3330/eleventy.config.js:3:9)
[11ty] at Object.fn (file:///Users/zachleat/Code/eleventy/src/Benchmark/BenchmarkGroup.js:36:23)
[11ty] at ShortcodeFunction.run (file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:235:29)
[11ty] at Template.root [as rootRenderFunc] (eval at _compile (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:64)
[11ty] at Template.render (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:454:10)
[11ty] at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:444:10
[11ty] at new Promise (<anonymous>)
[11ty] at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:443:11
[11ty] at Template._render (file:///Users/zachleat/Code/eleventy/src/TemplateContent.js:588:25)
[11ty] at async TemplateMap.populateContentDataInMap (file:///Users/zachleat/Code/eleventy/src/TemplateMap.js:537:7)
[11ty] Wrote 0 files in 0.03 seconds (v3.0.0-alpha.17) |
Operating system
Xubuntu 22.04
Eleventy
2.0.1
Describe the bug
I have a fairly standard setup using an image shortcode to generate responsive images.
I use this several times in a template that consumes JavaScript data from Strapi, e.g.
{% image industrial.attributes.roadmapPhoto.data.attributes.url, "Roadmap photo", "img-fluid rounded-3", "(max-width: 500px) 100vw, (max-width: 750px) 100vw, (max-width: 1000px) 100vw" %}
However, if
industrial.attributes.roadmapPhoto.data.attributes.url
is undefined, we get an error as per below.The problem is that 11ty doesn't tell me where in the template it failed, which is frustrating as this shortcode is used in tens of places in the template, so I have to start commenting them out to see what happened. Can this information be exposed?
Note that running with
DEBUG
doesn't add any more useful information.Reproduction steps
No response
Expected behavior
No response
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: