01 January 2007

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:

  1. Template directory inheritance: each directory can override specific templates from its parent template directories.
  2. In-memory templates: dynamic templates and database-driven templates require allowing non-file templates to be compiled and referenced.
  3. 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:

  1. Compiled templates are cached
  2. Templates can be loaded from variables or from the server
  3. 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:

  1. Basic conditionals, substitutions and loops are fully supported
  2. Data can be assigned using XPath:
    tple.assign "var", "val"
    tple.assignByXpath "/loop[1]/sub[1]/var", "val"

 

Technologies:


blog comments powered by Disqus