Haml和液体模板在一起



我试图在我最近安装的机车中使用haml和液体,我遇到的问题是让变量与link_to和image_to一起工作。下面是一个使用link_to的例子,我想在循环

中获取段塞
{% 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 %}

使用haml液体的答案

#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 %}

相关内容

  • 没有找到相关文章

最新更新