The Smarty templating language hold mass appeal for its usability and simple separation of interface and application. I have built several engines that use the same syntax with adjustments to handle the differences in programming languages. The Pithy rendering engines mimic the syntax of Smarty, but they add various extra capabilities.
The language was ported to various languages to provide a common denominator for my staff at Uppercase Development. By reducing the number of technologies to learn, training time was kept under control as we addressed projects in languages other than PHP.
PHP - Pithy is a Smarty wrapper
In PHP, Pithy extends and enhances the Smarty engine. It adds the following key features:
- Template directory inheritance: each directory can override specific templates from its parent template directories.
- In-memory templates: dynamic templates and database-driven templates require allowing non-file templates to be compiled and referenced.
- Class-based plugins: custom functions, methods and blocks can be created by registering classes. This allows easier creation of methods and functions that can be accessed in multiple ways. It also keeps logic in the GoRad namespacing and allows for alternate use of the plugins.
JS - Pithy is an AJAX tool
In JS, Pithy has a few unique characteristics:
- Compiled templates are cached
- Templates can be loaded from variables or from the server
- When loaded from the server, Pithy handles the async process to perform AHAH placement of output
VBA/VBScript - Pithy is an XPath tool
VBA and VBScript required separate codebases, but their Pithy features are identical. The relevant distinction for these languages is the lack of a basic multi-dimensional hash. Although it is possible to work around that, a more natural approach was taken:
- Basic conditionals, substitutions and loops are fully supported
Data can be assigned using XPath: tple.assign "var", "val" tple.assignByXpath "/loop/sub/var", "val"