-
I was finding that I was rewriting code over and over (getNote, getContent, etc. etc. etc.). It was a pain to have to copy the code to new notes and, if there was an improvement, have to go to all those locations to make the change. Additionally, I have some JSON charting code, where each chart's code is identical, except for a configuration object. SO, tonight I started thinking about how to have some code reuse. And it worked! Implementing Dynamic Includes: Example Tree Structure:
Steps:
Now, anytime you load the render note, both SomeJSNote and SomeJSNote2 will be added to the output and executed. I have attached an exported tree demonstrating this... Hope this helps someone! I am using it a ton! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There's several different ways you could go about something like this. Some other easy alternatives:
And something that takes a little more setup but is my personal preference and what I'm currently doing:
|
Beta Was this translation helpful? Give feedback.
There's several different ways you could go about something like this. Some other easy alternatives:
script
with thesrc
having the patternapi/notes/{noteId}/open
which will "remotely" link that scriptwindow
object from a central script and just calling specific functions in the local scriptwindow
so one script listens forwindow.addEventListener("my-event")
and another triggerswindow.dispatchEvent("my-event")
eval
them (or more preferably an indirect eval)And something that takes a little more setup but is my personal prefe…