Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Load Templates Directly



Description

You can also render and load templates on fly as dynamic pages. The following code demonstrates the use of templates as dynamic pages −

index.html

<script type = text/template7" id = about">
   <div class = pages">
      <div data-page = about" class = page">
         <div class = page-content">
            <div class = content-block">
               <div class = content-block-inner">
                  <p>Hello, i am <b>{{firstname}} {{lastname}}</b>, 
                     <b>{{age}}</b> years old and working as <b>{{position}}</b> 
                     at <b>{{company}}</b>.</p>
               </div>
            </div>
         </div>
      </div>
   </div>
</script>	

The required data is fetched from template7Data. To specify the required template, you need to use data-template attribute with template id.

You can use JavaScript View's .load () method and template property to pass custom data as shown in the following instance −

mainView.router.load ({
   template: Template7.templates.aboutTemplate, 
   context: {
      firstname: 'William',
      age: 27
   }
})	
framework7_template7_pages.htm
Advertisements