JSON不使用Panini加载
我正在使用Zurb基金会的电子邮件 ,我正在创build一个非常简单的多语言电子邮件导出系统,我有这个data/lang.json
:
{ "en": { "hello": "hello", "welcome": "Welcome to my website" }, "fr": { "hello": "Bonjour", "other": "Bienvenue sur mon site web" } }
..并根据<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
的lang
属性
我需要从JSON中使用相应的对象。
Zurb使用Panini和把手,所以我正在做这个开始:
{{lang.en.hello}}
..但没有显示在网页上。 我究竟做错了什么?
最有可能的是在第50行的gulpfile.babel.js中缺lesssrc / data目录。
.pipe(panini({ root: 'src/pages', layouts: 'src/layouts', partials: 'src/partials', helpers: 'src/helpers', data: 'src/data'
如果你想让浏览器重载function起作用,你还应该添加一个监视expression式与其他(约ln:106):
gulp.watch('src/data/**/*.json').on('change', gulp.series(resetPages, pages, inline, browser.reload));
另见https://github.com/zurb/panini
祝你好运!