plugin-templates icon indicating copy to clipboard operation
plugin-templates copied to clipboard

Templates which have note overview plugin code in them do not work

Open meldarionqeusse opened this issue 4 years ago • 2 comments

I tried creating a template which has a note overview (from note overview plugin) to get summary of tasks I have not completed. If you look at the code below the noteview in the template has {{notebook}} {{title}}, {{tags}} etc these get removed when I create note from template

This is the template:

---
project: dropdown(Work, Personal)
template_title: {{ subproject }} 
name: text
template_tags: {{#custom_datetime}}YYYY{{/custom_datetime}}, {{#custom_datetime}}MMMM{{/custom_datetime}},{{ project }} 

---

## {{ template_title }} - {{  name  }}

This note contains the meeting minutes of the weekly meet held on {{ datetime }} for {{ project }}.

<!-- note-overview-plugin
search: notebook:"My Notes" type:todo iscompleted:0
fields: title,body
alias: updated_time AS Last Updated, title AS Title
listview:
  text: "{{  notebook  }} > {{  title  }} {{  tags  }} <details> \r

    \ {{  body  }} \r

    \ </details>"
  separator: "<hr>\r\n"
-->

This is how it transforms when I create a note from template

 Test

This note contains the meeting minutes of the weekly meet held on 24/09/2021 10:47 for Work.

<!-- note-overview-plugin
search: notebook:"My Notes" type:todo iscompleted:0
fields: title,body
alias: updated_time AS Last Updated, title AS Title
listview:
  text: " >   <details> \r

    \  \r

    \ </details>"
  separator: "<hr>\r\n"
-->

meldarionqeusse avatar Sep 24 '21 08:09 meldarionqeusse

Yup, this is expected because the text of form {{ something }} is considered as variable by this plugin. But I'll explore if there's a way to allow users to use these braces as normal text.

nishantwrp avatar Sep 24 '21 14:09 nishantwrp

Hello, I ran into the same issue and found two possible workarounds. Here they are in case someone can find this useful.

Solution 1: Defining text with template custom variable

  • Define a template custom variable as a dropdown variable
    • e.g.: note_text: dropdown({{title}} ({{created_time}}))
    • By using a dropdown variable with a single choice it is filled automatically when creating a new note from template
  • In the note-overview section, use the variable defined above
listview:
  text: "{{note_text}}"

Solution 2: Escaping double curly brackets and defining note-overview-plugin as template custom variable

  • Similar principle as the first solution, but applied differently
  • Define a dropdown variable note_overview: dropdown(note-overview-plugin)
  • Define the note-overview section with <!-- {{note_overview}} instead of the standard <!-- note-overview-plugin
  • Escape {{}} in the note-overview section using \{{}}:
listview:
  text: "\{{title}} (\{{created_time}})"
  • See handlebars doc regarding escaping: https://handlebarsjs.com/guide/expressions.html#escaping-handlebars-expressions
  • Note that if the escape character \{{}} is used without the note_overview custom variable trick, then an error is thrown when the note-overview plugin tries to run on the template note

jbsauvan avatar Jul 03 '22 15:07 jbsauvan