hadynz / obsidian-kindle-plugin

Sync your Kindle notes and highlights directly into your Obsidian vault
MIT License
922 stars 52 forks source link

[BUG] Error occurs if Highlight template starts with a Nunjucks expression #203

Closed justjosh closed 1 year ago

justjosh commented 1 year ago

Describe the bug

I can only get the sync to work when {{ text }} is the first item in the Highlight template. I was trying to nest everything in an IF statement but found it results in this error when syncing. I also tried to simply change the order of the default template so that the note is printed first, but got the same error.

Method of syncing

To Reproduce

Steps to reproduce the behaviour:

  1. Enter the following highlights template
    
    {% if note %}{{note}}{% endif %}
    {{ text }} — location: [{{ location }}]({{ appLink }})

2. Attempt to sync (either via Amazon or Clippings file)
3. Results in the following error:

Template render error: (unknown path) TypeError: Cannot read properties of undefined (reading '0')



### Expected behaviour
Would expect to be able to use a Nunjucks expression above the line `{{ text }}` in the highlight template.

### Metadata
 - OS: Windows
 - Plugin version [e.g. 1.7.0]
 - Obsidian version [e.g. 0.15.9]
hadynz commented 1 year ago

Wow. I never expected this to be an issue. I can confirm that I've been able to replicate the problem. Will look into it now

hadynz commented 1 year ago

This is now fixed in 1.8.1

justjosh commented 1 year ago

Legend! Confirmed issue is fixed, thanks!