2013-04-04 40 views
2

我正在使用Middleman和Slim模板。Middleman Slim模板 - 有沒有辦法將變量傳遞到YAML前端?

我代理數據自動創建多個頁面。我需要設置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' 

回答

4

在你config.rb添加一行:

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

這應該做的伎倆。

相關問題