Post AYJTbAw988x95twVBQ by dcbuchan@aus.social
(DIR) More posts by dcbuchan@aus.social
(DIR) Post #AYHTzbQjtKMXtbypcm by anders@thoresson.social
2023-08-01T08:20:20Z
0 likes, 0 repeats
Are nested templates possible in #Obsidian, letting you reuse sub-templates/scripts in many places?
(DIR) Post #AYHUNZb4MLa59yF42C by matti@social.lol
2023-08-01T08:24:34Z
0 likes, 0 repeats
@anders Have you tried templater? https://silentvoid13.github.io/Templater/ You can for sure at least reuse scripts between your #obsidian templates with that one.
(DIR) Post #AYHUeedqr82tjGgjtg by anders@thoresson.social
2023-08-01T08:27:45Z
0 likes, 0 repeats
@matti Yeah, Templater is one of the solutions I’m looking into. But can’t get my head around wether I can reuse snippets in multiple templates. As one example, I have a Dataview queries that I use in a couple different templates. Would be nice if that query could be stored in a file of its own, so that I only have to edit it once when I makes changes to it. #Obsidian
(DIR) Post #AYHVFhow04kSIoXWZk by matti@social.lol
2023-08-01T08:34:25Z
0 likes, 0 repeats
@anders You could totally do that with a script, that only returns that string:function getDataViewQuery() { const str = `\`\`\`dataviewLISTFROM #poemsWHERE author = "Edgar Allan Poe"\`\`\` `; return str;}module.exports = getDataViewQuery;And then you can just use it in templater template:<% tp.user. getDataViewQuery() %>
(DIR) Post #AYHVi4PZbKd2TXCbku by anders@thoresson.social
2023-08-01T08:39:34Z
0 likes, 0 repeats
@matti Nice!
(DIR) Post #AYIp5UbaTK22f4fEEC by dcbuchan@aus.social
2023-08-01T23:51:07Z
0 likes, 0 repeats
@anders @matti You can do that. It involves creating a .is file containing your dataview JavaScript and then using dataview to call that. The use Templater to provide the link to the call. I don’t have an example at work but if you dm me as a reminder I can provide it this evening.
(DIR) Post #AYJLuImdNjkDIa6QZE by matti@social.lol
2023-08-02T04:36:35Z
0 likes, 0 repeats
@dcbuchan @anders No worries, I already gave an example in my second reply. 👍
(DIR) Post #AYJLuJW0f22ZZJKfIG by dcbuchan@aus.social
2023-08-02T04:38:07Z
0 likes, 0 repeats
@matti @anders I've got a different way of doing it that I'll share.
(DIR) Post #AYJLuLUfJ09ZhiicTY by anders@thoresson.social
2023-08-02T05:59:08Z
0 likes, 0 repeats
@dcbuchan @matti Would be great if you could!
(DIR) Post #AYJSPcZSShKfN2FzjU by matti@social.lol
2023-08-02T07:12:01Z
0 likes, 0 repeats
@anders @dcbuchan I actually would be curious, too. 😅
(DIR) Post #AYJTbAw988x95twVBQ by dcbuchan@aus.social
2023-08-02T07:21:14Z
0 likes, 0 repeats
@matti @anders Thought it easier to write a blog post on how I use scripts to save on updates in #Obsidian Don't worry about the Dataview code. Use it as an example of the concept.https://quantumgardener.blog/2023/08/02/scripting-templates-in-obsidian/
(DIR) Post #AYJTbBmbz4v7icUOxc by anders@thoresson.social
2023-08-02T07:25:19Z
0 likes, 0 repeats
@dcbuchan Absolutely perfect! I have been thinking about how to put searches and such into snippet files that are called from my templates! Thanks a lot! @matti
(DIR) Post #AYJUB1rOM319Mtoau0 by dcbuchan@aus.social
2023-08-02T07:31:46Z
0 likes, 0 repeats
@anders @matti Glad I could help.