0
對象的關鍵
你好,我有JSON文件:<title>把手變量{{PAGE}}從頭部帕尼尼</title></head> tiile標籤是從data.JSON
{
\t "index" : "Main page",
\t "contacts" : "Find me!",
}
有是一個車把模板與帕尼尼使用(ZF):
<!doctype html>
<html lang="ru">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{#if page}}
<title>{{lookup data.this}}</title>
<link rel="stylesheet" href="assets/css/screen.css" />
{{/if}}
panini中的{{page}}是通過模板的頁面的名稱(不帶擴展名)。 ,我不知道如何編寫適當的模板來獲取數據對象的鍵值。我想像它,當解析index.html panini變量頁面的值爲「index」,contacts.html - 「contacts」和標題標籤中的魔術像這個data.index一樣工作。
這不會在真正的服務器上運行。它只能在本地計算機上工作以幫助快速開發。
的腳本必須對魔術進行切換:
//part of the gulpfile.js
gulp.task('pages', ['jade'], function() {
return gulp.src('src/pages/**/*.{html,hbs,handlebars}')
.pipe(panini({
root: 'src/pages/',
layouts: 'src/layouts/',
partials: 'src/partials/',
data: 'src/data/',
helpers: 'src/helpers/'
}))
.pipe(gulp.dest('dist'));
});
//part of the gulpfile.js
您能否提供您正在使用的腳本來嘗試渲染模板? –
是的,我更新了我的問題。 –