hogan-express icon indicating copy to clipboard operation
hogan-express copied to clipboard

Fix lambda context

Open tandrewnichols opened this issue 6 years ago • 0 comments

If you use a lambda inside a loop (or any construct that has a sub-context), you can't access the outer context the way you normally can with hogan. E.g.

/*
{
  data: {
    id: 12,
    list: [
      { foo: 'bar' },
      { foo: 'baz' }
    ]
  }
}
*/

{{#data.list}}
  <!-- This works because hogan allows you to access the outer context -->
  <h1>{{ data.id }}</h1>

  <!-- This doesn't (it prints nothing) because filters and lambdas (unintentionally) obscure the outer context -->
  <h1>{{#lambdas.someLambda}}{{ data.id }}{{/lambdas.someLambdas}}</h1>
{{/data.list}}

This PR also gets rid of coffeescript because it's an unnecessary and annoying extra step and because most people are more comfortable with javascript, and because es5/6 make coffeescript mostly redundant.

tandrewnichols avatar Jul 17 '17 19:07 tandrewnichols