Render Note

Article Image

Render Note is a special case of front-end scripting which allows rendering custom content inside a note. This makes it possible to create custom dashboards, or to use a custom note editor.

The content can either be a vanilla HTML, or Preact JSX.

Creating a render note

  1. Create a Code note with the:
    1. HTML language for the legacy/vanilla method, with what needs to be displayed (for example <p>Hello world.</p>).
    2. JSX for the Preact-based approach (see below).
  2. Create a Render Note.
  3. Assign the renderNote relation to point at the previously created code note.

Legacy scripting using jQuery

A static HTML is generally not enough for Scripting. The next step is to automatically change parts of the note using JavaScript.

For a simple example, we are going to create a render note that displays the current date in a field.

To do so, first create an HTML code note with the following content:

<h1>Current date & time</h1>
The current date & time is <span class="date"></span>

Now we need to add the script. Create another Code, but this time of JavaScript (frontend) language. Make sure the newly created note is a direct child of the HTML note created previously; with the following content:

const $dateEl = api.$container.find(".date");
$dateEl.text(new Date());

Now create a render note at any place and set its ~renderNote relation to point to the HTML note. When the render note is accessed it will display:

Current date & time
The current date & time is Sun Apr 06 2025 15:26:29 GMT+0300 (Eastern European Summer Time)

Dynamic content using Preact & JSX

As a more modern alternative to jQuery, it's possible to use Preact & JSX to render pages. Since JSX is a superset of JavaScript, there's no need to provide a HTML anymore.

Here are the steps to creating a simple render note:

  1. Create a note of type Render Note.

  2. Create a child Code note with JSX as the language.
    As an example, use the following content:

    export default function() {
        return (
            <>
                <p>Hello world.</p>
            </>
        );
    }
  3. In the parent render note, define a ~renderNote relation pointing to the newly created child.

  4. Refresh the render note and it should display a “Hello world” message.

Refreshing the note

It's possible to refresh the note via:

Printing

A render note can be printed or exported as PDF from the Note menu once its ~renderNote relation is set (see Printing & Exporting as PDF). Unlike other notes, it is printed exactly as it is displayed: the script does not run again, so what was typed, selected or loaded in the note is kept.

  • The content is laid out again at the width of the page, so elements sized by the script for the screen (such as charts) might not fit.
  • Scrolling areas, such as a table in a scrolling container, are printed at their full height, without a scrollbar.
  • To adjust the layout for printing, use a ~printCss relation.
  • The light colors are used for printing, whatever the current theme.

When a render note is printed as part of a List View collection, or from another view such as its attachments, it is not on screen, so its script runs again for the print. In a collection, the output is printed without the note's own styles.

Examples