O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Expressions

In the context of OpenSocial templates, expression refers to an evaluation of some data source that is embedded directly into a markup structure.

Expressions can be rendered in a template using a simple syntax:

${Expression}

Expressions may be embedded inside text nodes and attributes, but will not be honored by an implementing container if they are inside custom tags and attribute names—a subject we will explore later in this chapter.

In addition to basic data rendering, most standard arithmetic expressions and data comparison features can be applied to expressions:

Next Index: ${Index + 1}

The functionality of these expressions is based on a modified version of the JSP expression language. Even though there are definitions for these arithmetic and comparison features, some operators use an XML escaped alternative for comparisons, such as when implementing OpenSocial template os:If statements. These escaped versions are listed in Table 7-7.

Table 7-7. Escaped versions of comparison operators

Conditional

Escaped string

Description

<

lt

Less than

>

gt

Greater than

<=

lte

Less than or equal to

>=

gte

Greater than or equal to

&&

and

And

==

eq

Equals

!=

neq

Not equals

||

or

Or

!

not

Not

By default, expressions are evaluated as escaped strings before they are inserted into the HTML document. Expressions are the basis for the majority of what we do with OpenSocial templates, so it’s crucial that you have a basic understanding of them.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required