Special Variables
OpenSocial has a set of reserved special variables for working with
template data objects and processing the template. These
variables—Context
, Cur
, My
,
and Top
—each have different groups of
data that they can access and a different order of precedence during
loading. With the exception of ${Context}
, special
variables are not required when you’re referencing data. Since the
variables are not required, expressions will be evaluated against the
available special variables using the following
precedence load order:
${Cur}
${My}
${Top}
Context
The ${Context}
variable contains additional information—relating to
currently processed data objects and identifiers for the template—that
is used during the processing of the current template. This
information provides context for the data that is being processed or
rendered.
${Context}
contains three
variables:
Count
The total number of results available in the current data object being processed within a repeater structure. This alters the flow of a repeater element based on the total number of results.
Use:
${Context.Count}
Index
The current numeric index being processed within a repeater structure. Much like the
Count
variable,Index
allows you to alter the flow of the loop based on the current object index processed.Use:
${Context.Index}
UniqueId
Provides a unique identifier for the current template. This value can be used to generate custom IDs for DOM nodes in the template markup.
Use:
${Context.UniqueId}
Cur
The ${Cur}
variable
refers ...
Get Programming Social Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.