2

编辑:更新的代码和解释

这是 application.html.erb:

<div class="container">
  <div class="row">
    {{outlet}} 
  </div>

  <hr>

  <footer>
    <p>&copy; 2013</p>
  </footer>

</div>

然后这是countries.hbs我要转换为标志的文件。

    <div class="span3">
      <div class="well sidebar-nav">
        <ul class="nav nav-list">
          <li class="nav-header">Countries</li>
          {{#each model}}
            <li>
              {{#linkTo "country" this}}{{title}}{{/linkTo}}
            </li>
          {{/each}}
        </ul>
      </div>
    </div>
    <div class='span9'>
      {{outlet}}
    </div>

基于Emblem docs,这是我能得到的最接近的结果,并且我尝试了变化,但我无法让它工作。语法是什么?

.span3
  .well.sidebar-nav
    ul.nav.nav-list
      li.nav-header Countries
      each model
        li = linkTo "country" #{title}

.span9
  {{outlet}}

我知道,部分问题是会徽似乎没有{{outlet}},所以我知道最后两行不起作用。

我正在使用better_errorsRails gem,这是错误:

Pre compilation failed for: .span3
  .well.sidebar-nav
    ul.nav.nav-list
      li.nav-header Countries
      each model

那么each循环有什么问题吗?

4

2 回答 2

1

这应该适合你。

  .span3
    .well.sidebar-nav
      ul.nav.nav-list
        li.nav-header Countries
        each model
          li
            linkTo "country"
              = title

干杯

于 2013-07-02T06:12:27.370 回答
0

您的代码中有一些语法错误。这应该有效:

.span3
  .well.sidebar-nav
    ul.nav.nav-list
      li.nav-header Countries
      each model
        li
          = link-to "country" | #{title}

.span9
  = outlet
于 2014-04-30T17:48:53.737 回答