#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-----------------------------------------------------------------------------
Macros and functions for working with properties and property lists
------------------------------------------------------------------------------>
<#-- Return true iff there are statements for this property -->
<#function hasStatements propertyGroups propertyName>
<#local property = propertyGroups.getProperty(propertyName)!>
<#-- First ensure that the property is defined
(an unpopulated property while logged out is undefined) -->
<#if ! property?has_content>
<#return false>
#if>
<#if property.collatedBySubclass!false> <#-- collated object property-->
<#return property.subclasses?has_content>
<#else>
<#return property.statements?has_content> <#-- data property or uncollated object property -->
#if>
#function>
<#-----------------------------------------------------------------------------
Macros for generating property lists
------------------------------------------------------------------------------>
<#macro dataPropertyListing property editable>
<#if property?has_content> <#-- true when the property is in the list, even if not populated (when editing) -->
<@addLinkWithLabel property editable />
<@dataPropertyList property editable />
#if>
#macro>
<#macro dataPropertyList property editable>
<#list property.statements as statement>
<@propertyListItem property statement editable >${statement.value}@propertyListItem>
#list>
#macro>
<#macro objectProperty property editable template=property.template>
<#if property.collatedBySubclass> <#-- collated -->
<@collatedObjectPropertyList property editable template />
<#else> <#-- uncollated -->
<#-- We pass property.statements and property.template even though we are also
passing property, because objectPropertyList can get other values, and
doesn't necessarily use property.statements and property.template -->
<@objectPropertyList property editable property.statements template />
#if>
#macro>
<#macro collatedObjectPropertyList property editable template=property.template >
<#assign subclasses = property.subclasses>
<#list subclasses?keys as subclass>
<#if subclass?has_content>
<#else>
<#-- If not in a subclass, list the statements in the top level ul, not nested -->
<@objectPropertyList property editable subclasses[subclass] template/>
#if>
#list>
#macro>
<#-- Full object property listing, including heading and ul wrapper element.
Assumes property is non-null. -->
<#macro objectPropertyListing property editable template=property.template>
<#local localName = property.localName>
#macro>
<#macro objectPropertyList property editable statements=property.statements template=property.template>
<#list statements as statement>
<@propertyListItem property statement editable><#include "${template}">@propertyListItem>
#list>
#macro>
<#-- Some properties usually display without a label. But if there's an add link,
we need to also show the property label. If no label is specified, the property
name will be used as the label. -->
<#macro addLinkWithLabel property editable label="${property.name?capitalize}" extraParams="">
<#local addLink><@addLink property editable label extraParams />#local>
<#local verboseDisplay><@verboseDisplay property />#local>
<#-- Changed to display the label when user is in edit mode, even if there's no add link (due to
displayLimitAnnot, for example). Otherwise the display looks odd, since neighboring
properties have labels.
<#if addLink?has_content || verboseDisplay?has_content>