shabegom / buttons

Buttons in Obsidian
The Unlicense
453 stars 47 forks source link

tp.user command in type note makes button dissapear #212

Open ZobaJakColbert opened 4 months ago

ZobaJakColbert commented 4 months ago

I was using this code to add new accumulator to my collection. It was getting current number of accu and adding one with .js script named: getThisAcumulatorNum. But now button don't show up. If I remove this line <% tp.user.getThisAcumulatorNum(tp, "AA") %> button reappears. How to fix this?

```button
name Add accu AA
type note(Accu/AA/<% tp.user.getThisAcumulatorNum(tp, "AA") %>, split) template
action Template - Accu
templater true
\```

remove "\" before last "```"

cacharbe commented 4 months ago

I'm seeing this behavior as well with embedded tp.user commands causing the button to not render.

From Console:

app.js:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path') at t. (app.js:1:722944) at app.js:1:237258 at Object.next (app.js:1:237363) at app.js:1:236279 at new Promise () at v (app.js:1:236024) at t.read (app.js:1:722825) at InternalModuleFile.generate_content (plugin:templater-obsidian:2402:28) at InternalModuleFile.create_dynamic_templates (plugin:templater-obsidian:2395:54) at InternalModuleFile.generate_object (plugin:templater-obsidian:2310:16) at InternalFunctions.generate_object (plugin:templater-obsidian:2892:60) at async templater$1 (plugin:buttons:989:23) at async eval (plugin:buttons:4311:38)

shabegom commented 4 months ago

Very strange that the whole button disappears. I'm guessing the way user script plugins work have changed in some way since I implemented the handling.

shabegom commented 4 months ago

@ZobaJakColbert can you post the script code so I have a minimal reproducible example? I currently don't have a user scripts.

cacharbe commented 4 months ago

I have repro'd the bug with the following minimal (change txt to js file):

name Add GM Session
type note(foo/bar/<% tp.user.getInt(tp) %>, split) template
action session-gm
templater true

^button-NewInt

getInt.txt

Tejeev commented 2 months ago

I am seeing this as well. Templater: v2.2.3 Buttons: v0.5.1