DocRaptor Home
PDF Code Examples

Code Example: Handlebar.js Templates

Here's how to make a PDF with Handlebar.js HTML templates:

    <script src=""></script>
    <script src=''></script>
    <script id="entry-template" type="text/x-handlebars-template">
      <div class="entry">
        <div class="body">
      var source   = $("#entry-template").html();
      var template = Handlebars.compile(source);
      var context = {title: "My New Post", body: "This is my first post!"}
      var html    = template(context);
      document.body.innerHTML = html;

Ready to get started? Try DocRaptor for free with unlimited test documents.