Template Plugin

2 Likes

All good here, thanks for a such a convenient and well implemented plug-in.

Do custom variable definitions need particular fencing? I directly copied your example, and it doesn't work as expected.

Test template

Date: {{date}}

Time: {{time}}

Datetime: {{datetime}}

Custom Datetime: {{#custom_datetime}}MMMM YYYY, h:mm:ss a{{/custom_datetime}}

Date of beginning of week: {{bowm}}

# Create custom variable example

---
name: text
color: enum(Red, Yellow, Green)

---

Hi there, {{ name }}. Your favorite color is {{ color }}. This note/to-do was created on {{ datetime }}.

Result

Date: 2021-08-07

Time: 7:41 PM

Datetime: 2021-08-07 7:41 PM

Custom Datetime: August 2021, 7:41:54 pm

Date of beginning of week: 2021-08-02

# Create custom variable example

---
name: text
color: enum(Red, Yellow, Green)

---

Hi there, . Your favorite color is . This note/to-do was created on 2021-08-07 7:41 PM.

I'm using joplin Joplin 2.1.9 (prod, win32)
I'm told when I try to upgrade that I have the latest version.
When I try and install your template I get this notice:
upgrade notice

Not sure what to do now.

@SteveShank
From the release post

  • Update to the latest pre-release of the desktop application i.e. 2.2.5 .

@johano

You have text bevor the fence block, witch starts and ends with ---.
In the exaple is the folowing code:

---
name: text
color: enum(Red, Yellow, Green)

---

Hi there, {{ name }}. Your favorite color is {{ color }}. This note/to-do was created on {{ datetime }}.

1 Like

Thanks Jack. I just glanced at it assured that I knew how to install a plugin.

Thanks, @JackGruber, all works fine now. I didn't understand the custom variables must be declared right at the start of the note and --- is the fence mark used.

Thanks for this plugin, installed it today and it works great!

1 Like
  • Is it possible to set the name/title of the note from the template? I want the name of the template to be the current date for instance.

  • Any way to create a note directly from a template without creating an empty note then applying a template?

  • Any way to modify how the date is represented? Currently, it is mm/dd/yyyy unlike it is shown in the doc 2019-01-01

  • Is it possible to position the caret after the template applied?

  • It would be nice to put the templated note under certain folder automatically.

1 Like

This one is opened as an enhancement request here: Option for note title in template · Issue #16 · joplin/plugin-templates · GitHub

You can do this from Tools > Templates > Create note from template or set a template as your default note template if you want to use a keyboard shortcut. I opened a request for a keyboard shortcut for the general case.

It seems the date is picking up the setting from Joplin. Preferences > General > Date format. Note, I had to restart Joplin to get this to be applied.

Not sure about these, but I agree both would be nice :slight_smile:

2 Likes

You mean the cursor? If yes, I don't know if that's possible with the plugin api. Maybe @laurent can tell that.

1 Like

You mean all your templates are stored in a single notebook? Initially, it was done that way. But the UX seemed not very simple. (Using a notebook instead of a folder to store the templates can cause various issues · Issue #12 · joplin/plugin-templates · GitHub)

1 Like

It's possible. You have full control over the editors using Plugins (markdown and WYSIWYG).

I think they might mean having a variable that would represent the destination notebook when creating a template, so that notes created based on a specific template would always go to the same folder. I believed it makes sense to do the same for having a title and tags.

2 Likes

Oh ok. Yes, it makes sense for title and tags. But, I don't get what will be the benefit of doing it for notebooks. You can simply go to that notebook and do create new note from template?

1 Like

Oh ok. Do you know how can we change the position of the cursor to a particular place using this?

I would prefer to configure the title in the template so that variables can be used, for tags that would be great too :slight_smile:

4 Likes

Please take a look at the linked documentation for how to set up a content script. Inside the content script you can use the CodeMirror setCursor function to set the cursor position. The documentation has an example for how this is done.

My use case is creating a new log file. From wherever I am, ideally I can hit a keyboard shortcut, then a new note is created in my Logs notebook, and I can continue on with what I was doing by hitting back. Having to navigate to the correct folder makes the keyboard shortcut less useful (although this is for sure an optimization, not completely critical! :slight_smile: )

I meant each template having its own destination folder. This way when I create a journal note from journal template, it will be moved a pre-defined journal folder.

The point is to save time with all this stuff. I do not want to worry about where my journal or todo folders are when using template notes. Imagine having 10 templates needing to be in special folders, that will require constantly moving around without this feature.

cc: @uxamanda @JackGruber @CalebJohn @kartoo

PS: I know that there were requests for specifying notebook as well in the template. But, I think we can discuss and implement this first. Because currently I couldn't find a way for user to know the notebook id.

2 Likes

Yes this is a problem, but I wouldn't take the notebook id, I would work with the name, only so you can choose e.g. dynamic the notebook for a project.