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.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.
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.)
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)
The following templates may be used:
{{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 onport
.{{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 (typicallynt-user
, although older content may be set toroot
).
These templates may be used in:
- Any test logic (code patterns, test cases inputs, etc.)
- Any scripts (setup, presave, build, etc.)
All embeds support Project templates.
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.
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 2yr ago