2015-08-28 67 views
0

下面是一個例子:Handlebars中{{#_}} ... {{/ _}}塊的含義是什麼?

 {{#_}}<strong class="point-submitter"> 
      {{#if submitter.avatar_url }} 
      <img src="{{ submitter.avatar_url }}" class="avatar" /> 
      {{^}} 
      <img src="{{ STATIC_URL }}css/images/user-50.png" class="avatar" /> 
      {{/if}} 
      {{#if submitter.name }} 
      {{ submitter.name }} 
      {{^}} 
      {{#if submitter_name }} 
       {{ submitter_name }} 
      {{^}} 
       {{ anonymous_name }} 
      {{/if}} 
      {{/if}} 
     </strong> {{ action_text }} this {{ place_type_label location_type}} 

     {{#if region}} 
      in {{ region }} 
     {{/if}}{{/_}} 

從這裏取: https://github.com/openplans/shareabouts/blob/master/src/sa_web/jstemplates/place-detail.html#L6

通過使用{{#_}} ... {{/_}}塊做有什麼區別?我在Handlebars documentation上找不到太多內容,而搜索諸如#_ handlebars block underscore之類的字詞並不是很有幫助。

回答

1

正如project architecture

說,這是鬍子的模板,而不是把手。 可以找到mustache.js的文檔here

{{#_}} ... {{/_}} - 是一個部分,其行爲依賴於_變量值。

正如Nick指出的那樣 - _變量包含i18n設置