Templates

Last updated 4 months ago

Lessons support a number of templates, which can be used throughout various parts of your lesson. 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 + Custom User Data Embeds

  • Into a Thinkific Course

  • Into a Teachable Course

  • 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 URL parameters).

Project Templates

Valid Templates

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 /root/sandbox).

  • {{localhost:port}} : The public URL of the container on port.

  • {{test}} : The filename of the test (either the one generated or the one overridden by you).

  • {{database}} : The name of the database set in the SQL results viewer.

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 Lesson

By using User templates in lesson 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.