fyears / weather-fetcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Templater usage issue

symph0nic opened this issue · comments

Hello! Firstly let me say that this is awesome.

Secondly, I'm having an issue - I have this set up to be called as part of my daily note, using Templater as follows:

<%* app.commands.executeCommandById("weather-fetcher:weather-insert") %>

Edit - Actually it's inserting the weather at the cursor position, which is the top of the file, not the location in the file where the above template command is located.

I am having a similar issue with the Templater content being inserted into a random location in my file.

Same here. Would be nice of having some way of using it from a template

Same issue. Has someone a solutions to this?

Hello peeps! I think I have a solution for y'all :)

Due to the plugin looking at the cursor position for where to insert the weather info-- simply manipulate the cursor's position programmatically within the Templater snippet.

<%* 
app.workspace.activeEditor.editor.setCursor(14, 1); // lineNumber, characterNumber
app.commands.executeCommandById("weather-fetcher:weather-insert") 
%>

Note: In my tests, it appears that it is actually inserting on 2 lines before what I indicate in the setCursor() function. I'm not sure if it will be the same for others, but do a couple experiments to see how it works for you.