0

我正在尝试在我最近安装的机车中使用 haml 和液体,我遇到的问题是让变量与 link_to 和 image_to 一起使用。下面是一个带有 link_to 的示例,我想在其中循环获取 slug

{% for article in contents.articles %}
      .media
        %a.pull-left{:href => '/our-club/club-news/{{article.slug}}'}
          %img.media-object{:alt => "64x64", "data-src" => "holder.js/64x64", :src => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAACv0lEQVR4Ae1a2WoqQRAtV+IW0OAuyYPGBXzy/7/ABxEUFfc8JNFAEnDHNfcUjFyDobnt9SEz1Q8z012T012nzqkJJLaPj48DWXjYLZw7py4EiAIszoBYwOICIFGAKMDiDIgFLC4AaYJiAbGAxRkQC1hcAPIVEAuIBSzOgFjA4gKQr4BYwOoWcF5CwGw2o263S/P5nO7u7ujh4YE8Hs8JZL1e5/jj4yOFQqGT2LnJNTDP7WOsaVtgt9tRpVKhxWJB0WiURqMRtdttA5fvb29vvD6dTmm73Z7Ezk2ugXlun7/XtBXw54+qtF6vqVgscmXj8TjPD4cD2Ww2QjIgBOuvr6/HPZ+fn+nl5YWSySQlEglqNBpMInBAlA7mEVzjQVsBn5+fvB2IKJfL1O/3Wf5IHuPp6Ylubm4oHA7z3LhEIhFaLpfU6XQICgEZPp+P39XFNLB17toEGJJGAk6nk8bjMbVaLT7DarWi4XBI8P334XK5KJvN0mazoVqtRm63+/ieLub3Pf5lrk0ADo5RKBSoVCoRKvv+/s6JDQYD8nq9/DyZTPg9Q96YxGIxrjrsgsYJAjEuwWQAjYs2Abe3t7wdEsVA90dC8D58jG5erVZZCYiDFJCAAanjy4GBnrDf7/n5EkwG0LhoN0HjsL1ej5sZLBAIBNjLUEUul+PjQBXNZpOVEgwGmSA0PlQ9lUoxQSAnnU6TLqZG3scf0SYADQ5eNpqZw+GgfD7PwIaUMYHnjbvdbuffG9AEM5kM3d/fc+9Av8Cn1O/3a2HyBpoX26X/IwTJIyFYACT8j3ENzJ/OdTEBPwH/lnXtJvhbElSdUwhQMWT2uCjA7BVW5ScKUDFk9rgowOwVVuUnClAxZPa4KMDsFVblJwpQMWT2uCjA7BVW5ScKUDFk9rgowOwVVuUnClAxZPa4KMDsFVblZ3kFfAGvb5MKWHSY9AAAAABJRU5ErkJggg==", :style => "width: 64px; height: 64px; "}/
        .media-body
          %h4.media-heading {{ article.title }}
          {{ article.body }}
      {% endfor %}
4

1 回答 1

4

使用带火腿的液体的答案

#home
  %h1 Blog Posts
  %ul.posts
    == {% for post in site.posts %}
    %li
      %span
        == {{ post.date | date_to_string }} 
        » 
        %a{:href => "{{ post.url }}"}
          == {{ post.title }}
    == {% endfor %}
于 2013-08-06T03:38:34.830 回答