shabegom / buttons

Buttons in Obsidian
The Unlicense
455 stars 47 forks source link

weird behavior when prepending template with multiple lines #96

Closed depressiveRobot closed 5 months ago

depressiveRobot commented 2 years ago

I am trying to prepend a template that contains multiple lines:

Template: _multiple_lines

first line
second line
third line

Note with button:

'''button
name Prepend multiple lines...
type prepend template
action _multiple_lines
templater true
'''

The lines will be added successfully for a very short moment and then only the first line remains while the others get replaced. Also, as more lines get inserted, more lines of the button code block itself get added up behind the original button code block. For example, with six lines added, the note contains the following code afterwards:

first line
'''button
name Prepend multiple lines...
type prepend template
action _multiple_lines
templater true
'''
type prepend template
action _multiple_lines
templater true
'''
dgou commented 2 years ago

I think I am seeing a similar issue using Obsidian 0.13.33 installer 0.13.31 I am not seeing anything in button maker (0.4.16) that gives an option for _multiple_lines though, which is why I am not sure if what I am seeing is part of this issue or not.

Anytime I use the templater true option in the button with either prepend or append and either text or template the text/template will be inserted and then disappear again. Since the button only works in view mode, I am not sure if this is a Live Preview issue or not. I also notice that sometimes when I have tried this a few times (watching the text flash into existence and then disappear again), when I go back into edit mode, the templater expression (I am testing with <% tp.date.now(format="HH:MM:SS" %> that the action is not reverted:

name Now
type prepend text
action 08:03:41
templater true

^button-now

vincentssn commented 1 year ago

I have meet the same prob. I want to use Buttons to implement 'Daily attendance' with code:

name attendance
type line(21) text
action data.push({date: "<%tp.date.now("YYYY-MM-DD")%>", content: "attendance"})
templater true
color green

If templater is true, when I click the button, the text will be inserted and then disappear after just one moment. Does it a known bug?