**[[Script]]** pages hold scripts for internal, dynamic, and repeatable use within the [[System]]. They rely on [[Obsidian]] and particularly the [[Dataview]] and/or [[Templater]] community plugins. ^about This is a [[Class]] within the [[System]], however these pages are a special case and do not list their class in the `classes` property. They are instead identified by existing within the unpublished `/system/scripts` folder. This is to accommodate for instances where frontmatter may interfere in how a script file may need to be used. ## Script Properties ```yaml --- script_type: script_local: script_cache: cache_file: cache_folder: cache_backlink: --- ``` Note that only the * properties should be found on all scripts pages. Others properties depend on the `script_type` itself. #### script_type* - **tpdv** - For dynamic versions of local vs publish queries per [[Pub Wrap#Dataview Caching]] - **tpdvjs** - As above but when the query is dataviewjs (WIP) - **dvthis** - Generic script, defined once, used in multiple pages, by relying on `this` context when script is called within `dv.execute(await dv.page("script file").script_local)`. Not compatible with Dataview caching (one script, many instances). - **dvjsthis** - As above but `dv.executeJs()` #### script_local* The script for when run locally (i.e. covering all files in the vault) #### script_cache The script to run when generating a *Dataview Cache* version (i.e. for the purposes of *Publish*, covering only those files in `/common/`) #### cache_file The name of the generated cache file when performing *Dataview Caching*. If this property is blank, no file is generated, even if there is a `script_cache` value. #### cache_folder The folder to place the cache file within. The default location is `common/cache`. #### cache_backlink The wikilink back to the page (or 'a page') that will be hosting (transcluding/embedding) the cache file. This link, along with the 'last generated' date, will be included in the generated cache file. This is required for usability since the cache file sits 'between' the host file and the backlinks on its transcluded table. Someone viewing one of the individual pages will only see a graph link to the cache file, not the host file itself. Presenting the link on the cache file lets the user 'finish the journey' to the host file. ## Script Invocations *Standard script invocations.* #### Standard invocation where the query sits in a property ```js // assuming "script_local" is the property dv.execute(dv.page("my script").script_local) // dql dv.executeJs(dv.page("my script").script_local) // dataviewjs ``` #### Standard invocation where the query is the page content itself ```js dv.execute(await dv.io.load("my_script_file.md")) ``` #### Complicated dataviewjs scripts requiring quote replacing ```js //change @ to whatever the substitue character(s) is/are dv.executeJs(dv.page("my script").script_local.replaceAll("@", "\"")) ``` ## Script Pages *Note that script pages are not published publicly. This area will be blank online.* <span class="dataview pws-tables-nowrap">`$=dv.execute(dv.page("Script (script)").script_local)`</span>