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

Rendering Templates

OpenSocial templates can be rendered in two ways:

  • Automatic rendering of the template on gadget load

  • Rendering the template via the JavaScript API

The first method listed, automatic rendering of the template, is the more widely accepted. Containers may disable the use of the JavaScript API for rendering templates on one, more, or all of their available views if they so choose. If this is the case, then only the automatic rendering method will be available. Despite this possibility, we’ll look at the implementation requirements for both types of template rendering. We’ll explore the concepts behind automatic rendering of templates next, and we’ll discuss using the template JavaScript API to work with and control templates via JavaScript methods later in the chapter, in the section JavaScript API.

Automatic rendering

Template markup placed within a script block with the type set to text/os-template is automatically rendered when the gadget loads. Should you want to prevent template blocks from automatically rendering, you can set a Param node within the Require element for the opensocial-templates feature to be disabled, as follows:

<Require feature="opensocial-templates">
  <Param name="disableAutoProcessing">true</Param>
</Require>

By default, the template markup will be inserted into the gadget in the location where the script block is placed within the gadget.

Should we want to embed a template within our existing HTML markup to display a welcome message to the current ...

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