Fork me on GitHub

AJAX and partial page rendering

The Snippetory Template Engine focuses on simplicity by leaving you full access on the power of the underlying technology. This means that on one hand you don't have to expect to much support. On the other hand you know exactly what you will get and the available functionality clearly arranged, no documentation orgies will be necessary. However, there is some functionality that is especially helpful for special needs. Here we'll focus on how this functionality can support development with AJAX.

Usable templates

The usable templates allow you to do quite a bit javaScript testing without the need to have the application running. This is especially challenging with java script. Hence, there is quite a number of things designed to smoothly inter-operate with those picky guys.

  • Randomly Select-able Syntax (RSS)

    The switch-able syntax allows to select the syntax that best fits your recent needs at any point of the template. Especially the HIDDEN_BLOCKS Syntax works well with java script.
  • Backward Replace

    If the flexibility, gained by RSS, is not enough, you can redirect the content targeted to a location mark or region. The backward attributes relocates the target to the last occurrence of a regular expression before the original target:


      var opts = $.datepicker.regional["de"]; // {v:lang backward='\"(de)\"'}

javaScript support in formatting

If you need to set date or or numbers within a javaScript block you might find some support in the predefined formats.

Partial Page Rendering

As the Snippetory templates are free of context, any region can be accessed directly and used independently. If we keep an eye on our code organization we're able to call the view logic directly, too.

Now we've only to recognize what type of request we're processing somewhere in our java code and get the snippet necessary to fulfill the request. This snippet might be a part of a whole template or the whole template or an aggregation. However, it then will be handed over to the method responsible for rendering it.

Bernd Ebertz

Head, Founder and chief technology evangelist of
jproggy.org
Java, and all Java-based marks are trademarks or registered trademarks of Oracle.
This site is not affiliated in any way with Oracle.