grunt-contrib-handlebars icon indicating copy to clipboard operation
grunt-contrib-handlebars copied to clipboard

Partial's context is undefined

Open JuoCode opened this issue 10 years ago • 0 comments

My partiial _navbar.hbs:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Dawn</title>
</head>
<body>

  <h1>Hello</h1>

  <nav>
    <ul>
      {{#each navbarItems}}
      <li>
        <a href="{{link}}">{{title}}</a>
      </li>
      {{/each}}
    </ul>
  </nav>

My page index.hbs:

{{> navbar }}

<div class="page-index">
  <h4>Home, {{name}}</h4>
</div>

I custome task in Gruntfile.coffee:

// require handlebars
Handlebars = require './vendor/handlebars/handlebars'

// custome task
templates = (require "./.tmp/jst/template")(Handlebars)
html = templates['index']({
  name: 'juo'
  navbarItems: navbarItems
})

Then i log the html, there is no li element in nav > ul

JuoCode avatar Feb 13 '15 10:02 JuoCode