Expanding ItemBlock Usability

Currently ItemBlocks are defined within the file-scope of an attribute template file. Recently it has been asked if instead ItemBlocks could be made available to all template files that have an include path to the file containing the ItemBlock.

Expanding ItemBlock Scope

It would be relatively easy to allow an Item Block in template file A to be available in template file B (assuming either B includes A or if there is a path of includes between A and B). The idea would be to cache the Item Block Information as a set of XML encoded strings after reading one include file, and then passing them down on when processing the files that include them.

Issue with Overriding ItemBlocks

The issue is “what if a consuming template file wants to override some of the ItemBlocks it is inheriting?”

To get a handle on this we need to review how include files are processed with reading in a template file.

Lets assume we have the following case:


In this case the top-level template file H includes template files F and G (in that order).

The order in which the include files are processed is the following:

Use Case 1 - all Item Blocks are Unique

So lets assume that the names of all of the ItemBlocks are unique (hence no ItemBlock is redefined. Based on the processing order, an ItemBlock defined in A would be available in the processing of all of the other template files since it is pulled in first. Note that Definitions defined in A are also currently available in the processing of all of the other template file as well. This behavior is similar to how include files are processed in C++.

Use Case 2 - Redefining ItemBlocks

Let’s assume that C has an ItemBlock called IBC and that F redefines it (IBC’). Also assume that G uses ItemBlock IBC. In the above example, G is going to inherit IBC’ since F is processed before G. If the designer was to change the order of includes in H such that G was included before F, then G would be using IBC instead.

@Aaron @waj334 @rohith @mledesma @dcthomp @johnt - FYI - Comments welcome!