【问题标题】:Middleman Slim template - is there a way to pass variables into YAML front matter?Middleman Slim 模板 - 有没有办法将变量传递到 YAML 前端?
【发布时间】:2013-03-26 19:04:52
【问题描述】:

我正在使用 Middleman 和 Slim 模板。

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

例如

在 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'

【问题讨论】:

    标签: ruby yaml slim-lang middleman


    【解决方案1】:

    在您的 config.rb 中添加以下行:

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

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 2016-08-26
      • 2019-08-18
      • 2014-11-07
      • 2014-09-10
      • 2022-06-29
      • 1970-01-01
      相关资源
      最近更新 更多