# 3. Learn backbone.js tutorial from scratch for beginners(Part 5) Underscore Templates in Backbone.js

C:\Users\Administrator\Desktop\gulp\index.html

```
<!DOCTYPE html>
<html>
<head>
  <title>Backbone Example</title>
  <link rel="stylesheet" href="lib\css\todos.css" />
  <script src="lib/js/jquery-1.9.1.js"></script>
  <script src="lib/js/underscore.js"></script>
  <script src="lib/js/backbone.js"></script>
  <script src="app.js"></script>
  <script type="text/template" id="ourTemplate">
    <h1>Hello 1</h1>
    <h2>Hello 2</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adip</p>
  </script>
</head>
<body>
  <div id="div1"></div>
</body>
</html>
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS331ZCMi-ftdOeUD3v%2F-MS365XPOhHGUwSHvdhG%2FScreenshot_5.jpg?alt=media\&token=9129ef45-ec6b-477f-ab64-4baa275ea345)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var theView = Backbone.View.extend({
    el: "#div1",
    template: _.template($("#ourTemplate").html()),
    initialize: function() {
      this.render();
    },
    render: function() {
      this.$el.html(this.template());
      return this;
    }
  });
  var page = new theView();
});
```

Hoặc viết theo một cách logic hơn&#x20;

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var theView = Backbone.View.extend({
    el: "#div1",
    template: $("#ourTemplate").html(),
    initialize: function() {
      this.render();
    },
    render: function() {
    	var template = _.template(this.template);
      this.$el.html(template);
      return this;
    }
  });
  var page = new theView();
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/advanced/5.-learn-backbone.js-tutorial-from-scratch-for-beginners-part-5-underscore-templates-in-backbone.js.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
