Question from the jQuery test

Given a template for an application, write a description of the template.

Medium

Considering the following code used to define a template for an application, what can we say about this code?


<script id="bookTemplate" type="text/x-jQuery-tmpl">
   <div>
     <img src="BookPictures/${picture}"alt=""/>
     <h2>${title}</h2>
      price: ${formatPrice(price)}
   </div>
</script>
<script type="text/javascript">
  // Create an array of books
    var books=[
       { title: 'ASP.NET 4 Unleashed', price: 37.79, picture: 'AspNet4Unleashed.jpg' },
       { title: 'ASP.NET MVC Unleashed', price: 44.99, picture: 'AspNetMvcUnleashed.jpg' },
       { title: 'ASP.NET KickStart', price: 4.0, picture: 'AspNetkickStart.jpg' },
       { title: 'ASP.NET MVC Unleashed iPhone', price: 44.99, picture: 'AspNetMvcUnleashedIPhone.jpg' }
    ];
  // Display the books using the template
    $('#bookTemplate').tmpl(books).appendTo('#bookContainer');
    function formatPrice(price){
        return '$'+ price.toFixed(2);
    }
</script>
Author: InconnuStatus: PublishedQuestion passed 243 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!