Fusebox parameter verb

The variable namespace in Fusebox 4.1 and earlier is completely flat. If you <include> a fuse (or <do> a fuseaction), any variables defined at the point of the <include> (or <do>) are visible directly inside the fuse (or fuseaction). Similarly, any changes made to those variables inside the fuse (or fuseaction) will leak back into the original fuseaction code. This makes it hard to write modular code.

Fusebox 5 introduces parameters for the <include> and <do> verbs. This lets you protect variables from being overwritten by an included fuse or an executed fuseaction, as well as allowing you to pass variables into a fuse or fuseaction without "polluting" the variables scope in the current fuseaction. You can specify one or more variables (and values) that are active only for the included fuse (or executed fuseaction). Any existing variables of the same name are pushed safely away and restored after the <include> (or <do>) is complete.

<include template="dspLayout">
<parameter name="title" value="Parameterized Layout" />
</include>

In this example, the variable title is given the value "Parameterized Layout" only for the duration of the dsplayout fuse. If there was variable called title defined before this <include> was executed, it is saved and then restored after the <include> is complete. Any changes made to the variable title inside dsplayout will not affect the original variable title.

The intent of the new <parameter> verb is to protect variables in the calling fuseaction from anything that the called fuseaction (or included fuse) does, allowing you to more easily reuse fuseactions and fuses without them overwriting your variables.

The name of a <parameter> may be either a simple variable name or a struct-qualified simple variable name, e.g., title, attributes.someVar, request.aName, myStruct.myKey. The value of a <parameter> may be omitted, in which case the variable keeps its current value but is still saved and if the fuseaction or fuse changes the value, the original value will be restored. The following two verbs are equivalent:

<parameter name="myVariable" value="#myVariable#" />
<parameter name="myVariable" />

You can also use the verb to pass variables into a global fuseaction since the <fuseaction> verb also accepts <parameter> verbs as children:

<fuseaction action="model.initialize">
<parameter name="dataSourceName" value="devNotes" />
</fuseaction>

As with <do> and <include>, any <parameter> variables specified for <fuseaction> will not pollute the main variables scope.