Scriptlets are little pieces of JavaScript embedded in a page that run when the page is exported, previewed, or used as a template. The syntax is VoodooPad's:
<% writer.write('Hello from a scriptlet') %>
<%= new Date().getFullYear() %>
The = form writes the expression's value; the plain form runs
statements and writes whatever you pass to writer.write(). (In this
manual the tags are typeset so they won't run; in your pages, just type them
normally.)
Code in a document is gated per document, and MojoPad asks once. Scriptlets, plugins and Event pages all wait behind the same question: do you trust this document to run code? Until you answer yes, none of them run — which is what stops a wiki somebody sends you from executing anything the moment you open it.
So if a plugin you just wrote appears to do nothing, this is the first thing to check. The answer is remembered per document, and only pages you wrote yourself are eligible in the first place — a page that arrived from a followed folder, an import, an agent or a link never runs, however it is named. See Only pages you wrote will run under Scripting: Event Pages.
| Object | Meaning |
|---|---|
writer.write(s) | append output where the scriptlet stands |
destination | web, pdf, epub, page, preview, or template — vary output by where it's going |
page.name | the page being rendered |
Errors render inline in red rather than breaking the export. Scriptlets run during every export, HTML preview, and template instantiation — they're how a page can contain the current date, a computed table, or different footers for web and PDF.