Templates
Contents support a number of templates, which can be used throughout various parts of your content. We'll mention these several times throughout this documentation.
A template has the form {{key}} or sometimes {{key1.key2}}. Different templates are supported, depending on where you are using the template.

User Templates

Valid Templates

The following templates may be used:
    {{user.first_name}} : The user's first name.
    {{user.last_name}} : The user's last name.
    {{user.email}} : The user's email address.

Valid Locations

These templates may be used in:
    Step contents, titles, or summaries
    Instruction titles, contents, positive or negative feedback
    Custom Codey messages
    Any test logic (code patterns, test cases inputs, etc.)
    Any scripts (setup, presave, build, etc.)

Supported Embeds

The following embed types can use User templates:
    Publishable Key Embeds
    LTI Embeds (as long as you've enabled user data submission in your LMS)
    Access Token Embeds (provided you use the first_name, last_name, and / or email)

Project Templates

Valid Templates

The following templates may be used:
    {{database}} : The name of the database set in the SQL results viewer.
    {{entry}} : The overridden project entry or the current option (filename) from the project.
    {{localhost}} : The public URL of the container on port 8080 (the default port for the static file server in the starting directory, usually /home/nt-user/workspace).
    {{localhost:port}} : The public URL of the sandbox on port.
    {{hostname}}: The project's hostname, e.g. venerated-cockatoo-1232.
    {{test}} : The filename of the test (either the one generated or the one overridden by you).
    {{username}}: The username of the project (typically nt-user, although older content may be set to root).

Valid Locations

These templates may be used in:
    Any test logic (code patterns, test cases inputs, etc.)
    Any scripts (setup, presave, build, etc.)

Supported Embeds

All embeds support Project templates.

Use Cases

Personalize the Content

By using User templates in content instructions, you can deliver a personalized learning experience.
Add their name to instruction feedback, explain the breakdown of their email in a regex tutorial, and much more.

Use in Program Tests

Ask the user to output their name, and then use a template as part of a test cases expected output to verify that they did so.
Or use a unit test to call a function like hello with their name to personalize their test results.
Last modified 9mo ago