在下面的示例中,我在客户端的lib文件夹中的utils.js文件中注册了一个帮助程序“currentUser”。如果条件满足,我试图将消息正确或左对齐。
id Edm.String Key, Searchable, Sortable, Retrievable
name Edm.String Searchable, Filterable, Sortable, Retrievable
adminEmails Collection(Edm.String) Searchable, Filterable, Retrievable
hrEmails Collection(Edm.String) Searchable, Filterable, Retrievable
description Edm.String Searchable, Filterable, Sortable, Retrievable
shortDescription Edm.String Searchable, Filterable, Sortable, Retrievable
image Edm.String Retrievable
thumbnail Edm.String Retrievable
country Edm.Int32 Filterable, Sortable, Retrievable
city Edm.String Searchable, Filterable, Sortable, Retrievable
postalCode Edm.String Searchable, Filterable, Sortable, Retrievable
street Edm.String Retrievable
number Edm.String Retrievable
box Edm.String Retrievable
rating Edm.Int32 Filterable, Sortable, Retrievable
boostFactor Edm.Int32 Filterable, Facetable, Sortable, Retrievable
tags Collection(Edm.String) Searchable, Filterable, Facetable, Retrievable
deleted Edm.Boolean Filterable, Sortable, Retrievable
addedDate Edm.DateTimeOffset Filterable, Sortable, Retrievable
changedDate Edm.DateTimeOffset Filterable, Sortable, Retrievable
banExpirationDate Edm.DateTimeOffset Filterable, Sortable, Retrievable
users Collection(Edm.String) Retrievable
currentJobs Collection(Edm.String) Retrievable
finishedJobs Collection(Edm.String) Retrievable
finishedJobsCount Edm.Int32 Filterable, Sortable, Retrievable
recommendations Collection(Edm.String) Searchable, Filterable, Retrievable
websites Collection(Edm.String) Searchable, Filterable, Retrievable
scoring profiles:
commonDields default profile fields: name (weight 1.5), shortDescription (weight 1.5), description (weight 1.5) and websites (weight 1.5) no functions -> function aggregation sum
mostRecent type: Freshness, field: changedDate, interpolation: Linear, boost: 1.5
byRating type: Magnitude, field: rating, interpolation: Linear, boost: 1.5
byBoostFactor type: Magnitude, field: boostFactor, interpolation: Linear, boost: 3
byTags type: Tag, field: tags, interpolation: Linear, boost: 1.5
帮助代码是:
<template name="chatMessages">
{{#each chatMessages}}
{{#if currentUser {{email}}}}
<b style="float:right;">{{message}}</b>
<br>
{{else}}
<b style="float:left;">{{message}}</b>
<br>
{{/if}}
{{/each}}
答案 0 :(得分:3)
不要将参数放在大括号内的助手中,即代替:
{{#if currentUser {{email}}}}
使用
{{#if currentUser email}}
假设变量email
是在帮助程序的数据范围内定义的! (你没有显示那部分)。