我正在中间人创建一个半静态网站。我创建了json本地数据。使用我当前的设置时,使用link_to时会出现 找不到文件
= link_to f.name, "speakers/#{f._id}.html"
我的网址看起来像
http://0.0.0.0:4567/speakers/53d544ea13dccbaf24521d98.html
speaker.yml
{
"people": [
{
"_id": "53d544ea13dccbaf24521d98",
"index": 0,
"status": false,
"profile_pic": "https://res.cloudinary.com/upload/v140671888/duncan_jnow.jpg",
"name": "Duncan Nieves",
"company": "QOT",
"position": "CFO",
"email": "duncannieves@qot.com",
"phone": "+33 (933) 598-3714",
"address": "813 Franklin Avenue",
"city": "Grantville",
"country": "Cyprus",
"biography": "Et reprehenderit aute adipisicing nostrud aliquip anim velit est ullamco non aliquip. Amet pariatur quis non dolor cupidatat nostrud enim sint ullamco occaecat. Reprehenderit est sint id est incididunt.\r\n",
"registered": "2014-02-27T15:40:41 -01:00",
}
]
}
然后循环数据
.section
.event-speakers
- data.speaker.people.take(12).each do |f|
.speaker.mobile-6.tablet-3.medium-2.large-2{itemscope: '', itemtype: 'http://data-vocabulary.org/Person'}
= link_to "speakers/#{f._id}.html" do
= image_tag f.profile_pic, width: '165', class: 'grayscale grayscale-fade'
%span.speaker-name{itemprop: 'name'}
= link_to f.name, "speakers/#{f._id}.html"
%span.job-title{itemprop: 'title'}
= f.position
%span.job-company{itempro: 'affiliation'}
= link_to f.company, "#", target: '_blank'
当我尝试添加以下内容时,我得到相同的结果。
data.speaker.people.each do |f|
proxy "/speakers/#{f[:_id]}.html", "speakers/layout.html",
:locals => { :f => f }
end
我得到了数据,但我无法弄清楚如何链接到一个人。我如何定义模板?
答案 0 :(得分:0)
您需要在speakers/layout.html.haml
目录中创建一个动态页面模板文件,source
。
在该文件中,您可以使用与索引页相同的语法,例如:
.speaker
%p.speaker-name
= f.name
%p.job-title
= f.position
%p.bio
= f.biography