PureScript offers built-in support for creating dynamic content or showing customized output to the user with the Text.Formatting.Template module. This module provides a simple string templating system.
To run the program, save it as Main.purs and use the PureScript compiler (psc) to compile it, then run it with Node.js:
This example demonstrates basic string templating in PureScript. While PureScript doesn’t have a direct equivalent to Go’s text/template package, we can achieve similar functionality using the Text.Formatting.Template module and custom functions.
Note that PureScript’s type system and functional nature lead to some differences in how we approach templating compared to Go. For instance, we use record types instead of structs, and we handle conditionals and loops using functions rather than special template syntax.