0

阅读 JSON 以进行运动。使用部分匹配标记。客队和主队在大多数情况下共享相同的标记,但我无法控制的 JSON 属性如下:

<div class="away {{game.awayTeam_last_name|slugify}}">
  <a href="#" title="{{game.awayTeam_first_name}} {{game.awayTeam_last_name}}">
    <span class="{{league}}-logo"></span>
<span class="city">{{game.awayTeam_first_name}}</span>
    {% if game.event_status != "pre-event" %}
      <span title="score">{{game.awayTeam_score}}</span>
    {% else %}
      <span title="record entering game">(0-0)</span>
    {% endif %}
  </a>
</div>
<span>@</span>
<div class="home {{game.homeTeam_last_name|slugify}}">
  <a href="#" title="{{game.homeTeam_first_name}} {{game.homeTeam_last_name}}">
    <span class="{{league}}-logo"></span>
    <span class="city">{{game.homeTeam_first_name}}</span>
    {% if game.event_status != "pre-event" %}
      <span title="score">{{game.homeTeam_score}}</span>
    {% else %}
      <span title="record entering game">(0-0)</span>
    {% endif %}  
  </a>
</div>

有没有办法像某些表达式评估器一样缩小/重构上面的内容,以使 home 和 away 通过变量传递。

4

1 回答 1

0

没有回答自己的问题,但我确实让数据人员更好地格式化数据,所以变成了.. awayteam: { first_name:'', last_name:'', score:'' } hometeam: { first_name:'', last_name: '', 分数:'' }

允许我将模板缩小一半 =)

于 2012-06-23T12:43:17.957 回答