Keeping scripts in Drafts and using js eval() in code editor


#21

I used your action and I like this way of doing it. It makes it very dynamic, since any draft with the specified tag(s) will be automatically included in script execution. It still seems pretty fast, even when including large libraries.

I tested it with the minified version if moment.js loaded into a draft. I can use the moment() functions with no issue in my scripts.

The only thing that would be nice is being able to trace errors a little better. Using the code from @draft8 earlier in the thread, the e.line property for the error message seems to include both the current script as well as the libraries put together. It would be great to know which script or function threw the error.


#22

I’d like the same as well. :grin: I haven’t figured out a good solution to address this yet. I keep bouncing back and forth between the usingLibs() and import_script() options. Both have some shortcomings, and short of @agiletortoise adding a Drafts version of import I’m not sure how far we can get.

I keep reminding myself our use of drafts in this way is niche and in the minority, and hopeful that later on in Drafts life there will be easier ways of doing some of this.


#23

True that. The usingLibs() is really making it a lot easier for me to debug and improve my JavaScript skills. I’m sure @agiletortoise will only be improving the scripting environment going forward. For now it’s just one extra step to include the usingLibs() script, so I’m happy!