Skip to content

Calculated Content in Templates via Inline Javascript #1237

@kleutzinger

Description

@kleutzinger

Describe feature

It would be cool if note templates had the ability to run inline javascript upon creation. Something like

Template content:

Today's date is: ${new Date()}

and then upon creating a note via the template the note's content becomes

Note content:

Today's date is: Thu Feb 20 2025 15:58:28

It would also be cool if template-created notes could modify their own attributes / title via javascript upon creation.

Workaround

You can kind of accomplish this with scripts attatched by #runOnChildNoteCreation or #runOnNoteCreation relations, but there's some race conditions with these events and the note's content / attributes. (I had to put a waiting-loop in my script waiting for the note to have content because when the script is intially run the note has no content or attributes yet. IIRC the title was present, though).

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BEIssues related to server-side/back-end

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions