InterJinn

Development Framework For PHP

Tag: <jinn:accumulate/>

Abstract

There are times when you know you need to include some information, perhaps a script, at a location in the content other than what the current context (perhaps an included template) allows. For these times an accumulator is useful. There are three major types: prepend, append and custom. The type is denoted by the where attribute. The prepend value is the only one with meaning since append is implicit if an explicit flush does not occur. The custom accumulator type works in tandem with the <jinn:accFlush/> tag. There is also a name attribute to ensure that accumulators don't intermix their contents and ultimately output a stew of information.

Attribute - where

This may be one of three values... prepend, custom, and append. If no value is set, or the value is invalid then the default is append. Prepend accumulators are flushed at the end of compilation to the very beginning of the content, right after any <jinn:prepend/> tag has been expanded. This is useful for including source or directives at the beginning of the content. The append accumulator does the oppposite and is automatically flushed at the end of the compiled content, before any <jinn:append/> tag has been expanded. The custom type requires the use of the <jinn:accFlush/> tag to be flushed at that location. If this flush tag is not included then the custom type will default to the append behaviour.

Attribute - name

You can avoid mixing accumulated data into a hodge podge stew by giving the accumulator a name. All content accumulated to a common name will remain separate from any other accumulated content.

A common accumulation I have found myself performing is for page specific CSS rules. It is extremely elegant to have rules appended to the any other rules in the header section of the HTML content and this is exactly the purpose for which accumulators exist.

Example:
<jinn:accumulate where="custom" name="playerCss" where="append">
td.playerlist
{
    font-size:10px;
    font-color:#990000;
}
</jinn:accumulate>