Middleman Slim模板 - 有没有办法将变量传递给YAML前端?

时间:2013-04-04 15:41:51

标签: ruby yaml slim-lang middleman

我正在使用Middleman和Slim模板。

我代理数据以自动创建多个页面。我需要用变量设置YAML前端,我不知道该怎么做!有谁知道吗?

E.g。

在config.rb

data.videos.expert_challenge_videos.each do |v|
  proxy "/live/expertchallenge/#{v.slug}.html", "/live/expertchallenge/template.html", :locals => { :v => v }, :ignore => true
end

在template.html.slim

---
title: Expert Challenge - #{v.name}
---
.live-single-video

  == partial 'header'

  .spacer

  .grid-container
    .grid-100.heading
      == image_tag "label-expertchallenge.png", alt: ''
  .grid-container
    .grid-100.video-container
      iframe src="http://area.autodesk.com/areaadmin/ooyala/show/ZobHQ4NzrsYP4CNnu2EijUGDRztihF7j/1000/562" width="1000" height="562" frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"

  .grid-container
    .grid-50.video-description
      .name
        | <b>Name:</b> #{v.name}
      .date
        | <b>Date:</b> #{v.date}
      .topics
        | <b>Topics:</b> #{v.topics}
    .grid-50.video-share
      | <div class="fb-like" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false" data-href="#{endpoint}/live/expertchallenge/#{v.slug}.html"></div>&nbsp;&nbsp;&nbsp;
      | <a href="https://twitter.com/share" class="twitter-share-button" data-url="#{endpoint}/live/expertchallenge/#{v.slug}.html" data-via="Autodesk_ME" data-text="#{v.name}">Tweet</a>

== partial 'footer'

1 个答案:

答案 0 :(得分:4)

在config.rb中添加以下行:

set :frontmatter_extensions, %w(.html .slim)

这应该可以解决问题。