ruby - Middleman Slim 模板 - 有没有办法将变量传递到 YAML Front Matter 中?

标签 ruby yaml slim-lang middleman

我正在使用 Middleman 和 Slim 模板。

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

例如

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

最佳答案

在 config.rb 中添加以下行:

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

这应该可以解决问题。

关于ruby - Middleman Slim 模板 - 有没有办法将变量传递到 YAML Front Matter 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15815742/

相关文章:

ruby-on-rails - 检查帖子是否在特定日期后发布

ruby-on-rails - pg gem 无法通过捆绑安装进行安装或根本无法安装

ruby-on-rails - Ruby XMLRPC 本地主机运行时错误 : Wrong Size

java - 从配置文件解析 Yaml

yaml - 使用单个 glob 模式包含多个没有已知根文件夹的子文件夹

html - 字符串内的 ruby

sublimetext - 在 Sublime Text 2 中使用 Zen Coding for Slim 的任何方法?

Ruby mixins 寻找最佳实践

escaping - 如何在 YAML 中转义指示符(冒号和连字符)

javascript - 作为 Slim 中元素属性的一部分的内联 Javascript 变量