wycats/handlebars.js — Issue #148: Mustache blocks not exhibiting conditional behaviour
Author: julianmack
Created: 2011-11-29 12:13:33+00:00
State: open

I have the following context:

var context = { Results: [
{ Name: "Store A", Distance: "3.14"},
{ Name: "Store B", Distance: "2.71"}
] };

...and Mustache template

{{#Results}}

{{Name}}
{{#Distance}}
{{Distance}} miles away
{{/Distance}}

{{/Results}}

If rendered using Mustache the {{#Distance}} block acts as a conditional. The span will be rendered with the value of Distance, e.g. "Store A 3.14 miles away".

Handlebars renders it as "Store A miles away" even when Distance has a value. The {{Distance}} in the span is not being rendered.

Is this a known issue? Do you have a workaround?