Developing render templates for W3C Verifiable Credentials can be a daunting task, especially given the technology's early stage. At Pyx, we recognised the need for a more efficient workflow and created the Pyx Render Template Studio—a web application designed to simplify the process for developers and trust architects.
Let's explore what render templates are, the challenges they present, and how our tool addresses these issues.
What Are Render Templates?
Render templates define how the contents of a Verifiable Credential are visually presented in a human-friendly, repeatable manner. They allow developers to apply a consistent template for each credential type. These templates can be embedded within render methods, which define how credentials are compiled and displayed for users.
The Render Method specification is still evolving, with various methods leveraging different templating syntaxes (like Handlebars or Mustache) and output formats (such as HTML, SVG, or PDF). This diversity, while powerful, introduces complexity.
The Problem with Existing Workflows
If you've ever developed render templates for Verifiable Credentials, you'll know the tooling options are limited. The typical workflow involves cobbling together various tools just to verify a single change—a process that's both time-consuming and error-prone.
Consider a simple task: truncating text within an element using the WebRenderingTemplate2022 method, which uses an embedded HTML template with Handlebars. You'd start by editing the HTML with Handlebars syntax, but you can't immediately see the result because the syntax placeholders aren't rendered. To preview the change, you might use a tool like Try-Dashbars, pasting your template and sample data, then clicking "compile" to see the output. This process, while functional, is cumbersome due to the tool's layout and the need to repeat it for every change—even if a bug is introduced.
Next, you need to construct a render method object that includes your template. This involves removing line breaks, escaping characters for JSON compatibility, and stringifying the result. Once done, you issue a Verifiable Credential, and send it to a compatible verification service to render it. If a bug is discovered, you must reverse the entire process and start again. For developers working on multiple templates, this workflow becomes exponentially more frustrating.
How Pyx Render Template Studio Helps
The Pyx Render Template Studio addresses these challenges with three core utilities:
1. Transform a Render Template into a Render Method Object
The Studio takes your render template, lets you select a render method (WebRenderingTemplate2022 or RenderTemplate2024), removes line breaks, escapes necessary characters for JSON, and constructs a render method object. The result is displayed for you to copy, streamlining the process significantly.
2. Reverse a Render Method Object into a Render Template
If you have a render method object, the Studio can extract the embedded or remote template (fetching it if needed), format it, and display it for copying. It auto-detects the render method (supporting WebRenderingTemplate2022 and RenderTemplate2024) and ensures the template is properly formatted.
3. Live Preview for Rapid Development
The live preview feature lets you input a render template, select the templating engine (currently Handlebars), and provide corresponding data. The Studio compiles the template and displays a dynamic preview that updates as you make changes. You can even resize the preview to test responsive designs, making it easier to iterate quickly.
These features have significantly increased the speed of developing and modifying render templates, particularly in real-world applications like in the development of the UNTP (United Nations Transparency Protocol) Specification.
Try It Out
The Pyx Render Template Studio is a game-changer for anyone working with render templates used in Verifiable Credential. We invite you to try it, request features, and share your feedback as we continue to improve the tool. Visit the Pyx Render Template Studio to get started and experience a more efficient way to develop render templates.
Join the Pyx Community!
- 📢 Chat on Pyx Zulip – Join real-time conversations with the community
- 💬 Join the Pyx Forums – Engage in discussions about the UNTP and related topics