Templater icon indicating copy to clipboard operation
Templater copied to clipboard

NaN as output if I use the + sign

Open merlinuwe opened this issue 1 year ago • 6 comments

Hi,

when I use the plus sign

creation_date: <%+ tp.file.creation_date("dddd, DD. MMMM YYYY, HH:mm:ss") %> Uhr

modification_date: <%+ tp.file.last_modified_date("dddd, DD. MMMM YYYY, HH:mm:ss") %> Uhr

as mentioned here https://silentvoid13.github.io/Templater/commands/dynamic-command.html

I get NaN in the file made with this template.


# <%+ tp.file.title %>

does also give NaN.

Windows 10, latest plugins, latest obsidian.

merlinuwe avatar Jan 30 '23 21:01 merlinuwe

Couldn't replicate bug. Switching to Preview mode from Edit mode displays the correct result from the dynamic command.

Windows 11 Home 22H2 Obsidian v1.1.9 (No other plugin installed other than Templater) Templater v1.16.0

img


Ok I think I get your problem though. When ever you insert template or create a new note with template, the dynamic code is executed instead of simply copying the dynamic code over as text.

Possibly the same issue as #910

welpdx avatar Jan 30 '23 22:01 welpdx

I highly recommend using dataview for this purpose instead, it works way more reliably for dynamic content, which is why this issue came up to deprecate dynamic commands at some point #913

Zachatoo avatar Feb 01 '23 03:02 Zachatoo

@Zachatoo Ah I see! That's why the function was nominated for deprecation!

welpdx avatar Feb 01 '23 04:02 welpdx

Ok I think I get your problem though. When ever you insert template or create a new note with template, the dynamic code is executed instead of simply copying the dynamic code over as text.

This is the actual issue, that I have, too.

afcuttin avatar May 25 '23 08:05 afcuttin

I highly recommend using dataview for this purpose instead, it works way more reliably for dynamic content, which is why this issue came up to deprecate dynamic commands at some point #913

@Zachatoo How would you use dataview for this purpose though? Do you mean insert a dataview query in the template file?

BarryBurton57 avatar Jun 13 '23 15:06 BarryBurton57

Yes, exactly. Other plugins tend to work great with Templater in this regard.

<% tp.file.title %>
More of whatever...

```dataview
dataview stuff
```

Or inline dataview `= this.whatever`

Zachatoo avatar Jun 17 '23 23:06 Zachatoo