1
Я выполняю итерацию через контроллер массива для отображения элементов - и в этом представлении я пытаюсь выполнить специальный помощник Handlebar с контекстом текущего адреса, однако внутри моего помощника объект не определен ,Handlebars helper - объект не работает
Вид:
{{#each temporaryUser.addresses}}
{{#view App.AddressView addressBinding="this"}}
{{addressActions view.address}}
{{{view.address.display}}}
<a {{action deleteAddress target="view"}} class="delete">Delete</a>
{{/view}}
{{/each}}
Handlebars.registerHelper('addressActions', function (address) {
var display = '<div class="actions">';
if (address.current && address.permanent) {
display += '<p>This is my current residential, and permanent address:</p>';
}
else if (address.current && !address.permanent) {
display += '<p>This is my current residential address:</p>';
display += '<a href="#">Make permanent residential address</a>';
}
else if (!address.current && address.permanent) {
display += '<p>This is my permanent address:</p>';
display += '<a href="#">Make current residential address</a>';
}
else {
display += '<a href="#">Make current residential address</a><br/>';
display += '<a href="#">Make permanent residential address</a>';
}
display += '</div>';
return new Handlebars.SafeString(display);
});
Ваш путь не работает. У меня есть аналогичный помощник, который работает с: 'Ember.Handlebars.helper ('ternary', function (condition, a, b) { Условие возврата === 'true'? A: b; });', которое я состоящий из объединения различных документов ... –