Documentation for a historical release of Infusion: 1.3
Please view the Infusion Documentation site for the latest documentation.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Advanced Renderer Driving

Going beyond simple calls to selfRender (from which the return value is the parsed template, allowing simple further "re-instantiation" of the templated markup), it is possible to drive the process in a more advanced, manual fashion - this is appropriate especially when rendering with multiple templates.

Fetching (multiple) resources using resourceSpec

The core driver for rendering a multiple template set will involve a call to fluid.fetchResources, which is capable of fetching multiple template segments via multiple modalities (via AJAX, or from various kinds of armouring in the current document). This works on "data-driven" records known as a resourceSpec. This table documents the fields and workflow of a resourceSpec:




A full resolvable URL holding a template or template fragment. This will be fetched via AJAX and used to populate the resourceText entry


The id of a node within the current document holding a template, for which innerHTML is to be treated as a template (needs to be upgraded, to not only handle general selectors for locating the node, but also to undoing differing grades of armouring, whether by comment, textarea or other)


Computed from href, in order to rebase local URLs in the template.


The full text of the template fragment, as a string


A reserved flag by the system to track the progress of AJAX calls

The top-level driver for parsing a multiple template set is fluid.parseTemplates:

  fluid.parseTemplates = function(resourceSpec, templateList, opts)

The first argument is a hash of names to resourceSpec records as described above - the second argument is a list of strings, which selects the particular set of records to be parsed for this call, and finally a hash of option elements - the options structure for rendering has its own section. The return value is a complex structure consisting of a list of template representations and indexes which will not be described here, but can be passed as the argument to fluid.renderTemplates

    fluid.renderTemplates = function(templates, tree, opts, fossilsIn)

The first argument here is the return from parseTemplates, the second argument is the component tree, third optional argument is again an options structure, and the fourth argument (optional) is a hash into which any fossils accumulated during the rendering process will be accumulated, as a form of "second function return".

fluid.selfRender is simply a convenient package or driver for the underlying base engines parseTemplates and renderTemplates to cover simple and common cases. An analogous package, for rendering again, using an already parsed template set, is called fluid.reRender.