Open In App

How to create an ember handlebars template ?

Ember uses the handlebars template library to modify the app’s user interface. Handlebars are just like the HTML code but they give additional features to developers like adding expressions that can change the displaying page. We can use the other features of handlebars to get a clear idea of ember handlebars. Once you tell the ember to render the template that you have created then there is no need to write extra code because handlebars can handle that thing easily.

Steps:



Define Template: If you don’t use build tools then you can simply define your application’s template inside your HTML using a script tag.




<html>
<body>
    <script type="text/x-handlebars">
      Hello, <strong>{{first_Name}} {{last_Name}}</strong>!
    </script>
</body>
</html>




<html>
<head>
    <script type="text/x-handlebars" data-template-name="tempName">
      <div class="my-class1">{{first_Name}}</div>
    </script>
</head>
</html>

HandleBars Expressions:



Hii, <strong>{{first_Name}} {{last_Name}}</strong>!!!
App.ApplicationController = Ember.Controller.extend({
  first_Name: "Dreke",
  last_Name: "Pirnick"
});
Hii, <strong>Dreke Pirnick</strong>!!!

Article Tags :