Our goal in submitting these two proposals for templating
and data linking is to make it easier to work with data when building websites
and applications with jQuery. Templating makes it easier to display a list of
database records retrieved from a database through an Ajax call. Data linking
makes it easier to keep the data and user interface in sync for update
scenarios.
Currently, we are working on an extension of the data
linking proposal to support declarative data linking. We want to make it easy
to take advantage of data linking when using a template to display data.
For example, imagine that you are using the following
template to display an array of product objects:

Notice the {{link name}} and {{link price}} expressions.
These expressions enable declarative data linking between the SPAN elements and
properties of the product objects. The current jQuery templating prototype
supports extending its syntax with custom template commands. In this case, we
are extending the default templating syntax with a custom template command
named “link”.
The benefit of using data linking with the above template is
that the SPAN elements will be automatically updated whenever the underlying
“product” data is updated. Declarative data linking also makes it easier
to create edit and insert forms. For example, you could create a form for
editing a product by using declarative data linking like this:

Whenever you change the value of the INPUT elements in a
template that uses declarative data linking, the underlying JavaScript data
object is automatically updated. Instead of needing to write code to scrape the
HTML form to get updated values, you can instead work with the underlying data
directly – making your client-side code much cleaner and simpler.
Downloading Working Code Examples of the Above Scenarios
You can download
this .zip file to get with working code examples of the above
scenarios. The .zip file includes 4 static HTML page:
Listing1_Templating.htm – Illustrates basic templating.
Listing2_TemplatingConditionals.htm – Illustrates templating
with the use of the if and each template commands.
Listing3_DataLinking.htm – Illustrates data linking.
Listing4_Converters.htm – Illustrates using a converter with
data linking.
You can un-zip the file to the file-system and then run each
page to see the concepts in action.