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.

Nunjucks filters in Highlight template throws Template render error

See original GitHub issue

Thank you for creating this plugin, much appreciated.

I’m trying to use Nunjucks filter ‘replace’ in the Highlight template,


{{ text | replace('4', '.') }}

{% if note %}{{note}}{% endif %}

---

But it results in template render error,

Error parsing
.../My clippings.txt.

Template render error:(unknown path)
TypeError: Cannot read property 'lineno' of undefined

My actual goal is to use regex with the replace filter, But since it didn’t work I tried a basic replace as sighted above.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
hadynzcommented, Nov 13, 2021

So that we can confirm if the original issue that you had raised was resolved by the last release, you can bypass the validation that the plugin uses and modify the plugin’s data.json file directly. Simply set highlightTemplate to the nunjucks template that you want and it should be picked up by the plugin.

I’ll look into fixing the false negative issue of validation after I am done with another task.

2reactions
hadynzcommented, Nov 10, 2021

Thanks for raising this @abishekmuthian. I understand this issue and it is a valid bug.

To support resync, the plugin adds a “block reference” (e.g. ^ref-1233) at the end of a highlight (rendered using {{ text }} tags in nunjucks). The plugin has not catered for the fact that you could be using a nunjucks modifier such as replace to manipulate the content.

Will fix shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nunjucks templating docs
Filters are essentially functions that can be applied to variables. ... It might be useful to not throw an error if a template...
Read more >
node.js - find which template file causes "template render error"
1 Answer 1 · filename -> absolute path to the file causing the error · tmplStr -> all the contents of that file...
Read more >
WebC — Eleventy
Using Eleventy's built-in Render plugin allows you to render WebC inside of an existing Liquid, Nunjucks, or 11ty.js template. View this example in:...
Read more >
CHANGELOG.md | lume@v0.22.6 - Deno
The format is based on Keep a Changelog, and this project adheres to Semantic ... Updated nunjucks (a new fork) and highlight.js ....
Read more >
Four Killer Features of Nunjucks | CSS-Tricks
This is meant to be run in Node.js and used to compile templates server ... showing me run a Node script that renders...
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