In-line template composition declaration


Template compositions are predefined chunks of SMXML to be used as templates for recurring patterns in your UI composition.

You may declare template compositions within a template tag anywhere inside a composer node of your SMXML. Pretty much the same rules apply as for all templates. All template composition declarations must appear as child nodes of a <template/> node in SMXML.

In the example below we apply the templateCompositionExample template on a couple of composer component instances by setting their template attribute to 'templateCompositionExample'. Note that they maintain the SMXML composition within both composer, yet they are free to be positioned, scaled or rotated.

SMXML
<!DOCTYPE composer SYSTEM "http://dtd.samplemath.com/smxml.dtd">
<composer>
    <style>
        <fill style="fillBlue" type="solid">
            <color>0x0000ff</color>
        </fill>
        <fill style="fillRed" type="solid">
            <color>0xff0000</color>
        </fill>
    </style>
    <template>
        <composer template="templateCompositionExample" >
            <box width="50%" height="50%" fill="fillBlue"/>
            <box x="50%" y="50%" width="50%" height="50%" fill="fillRed"/>
        </composer>
    </template>
    <box id="background" width="100%" height="100%" alpha=".1" rounded="24"/>
    <composer template="templateCompositionExample" x="120" y="30" width="100" height="100"/>
    <composer template="templateCompositionExample" x="380" y="40" width="160" height="80" rotation="-4"/>
</composer>

OUTPUT





Applying template compositions


The same rules apply as for applying templates. If a template (composition) specifies complex content for an SMXML node, the children of the instance node are set to this complex SMXML content. If a template applied has no content, the original SMXML content of the composer prevails.

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki