JSON不使用Panini加载

时间:2022-11-18 17:01:55

I'm using Zurb Foundation for Emails and I'm looking to create a really simple multi-language email export system where I have this data/lang.json:

我正在使用Zurb Foundation for Emails,我正在寻找一个非常简单的多语言电子邮件导出系统,我有这个数据/ lang.json:

{
  "en": {
        "hello": "hello",
        "welcome": "Welcome to my website"
  },
  "fr": {
          "hello": "Bonjour",
          "other": "Bienvenue sur mon site web"
  }
}

.. and based on the lang attribute of <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

..并基于

I need to use the corresponding object from the JSON.

我需要使用JSON中的相应对象。

Zurb uses Panini and Handlebars so I'm doing this to get started:

Zurb使用Panini和Handlebars,所以我这样做是为了开始:

{{lang.en.hello}}

.. but nothing shows up on the page. What am I doing wrong?

..但页面上没有任何内容。我究竟做错了什么?

1 个解决方案

#1


2  

Most likely there the src/data directory is missing in the gulpfile.babel.js around line 50.

很可能在第50行的gulpfile.babel.js中缺少src / data目录。

.pipe(panini({
      root: 'src/pages',
      layouts: 'src/layouts',
      partials: 'src/partials',
      helpers: 'src/helpers',
      data: 'src/data'

If you want the browser reload function to work you should also add a watch expression with the others (around ln:106):

如果您希望浏览器重新加载功能正常工作,您还应该与其他人一起添加监视表达式(在ln:106附近):

gulp.watch('src/data/**/*.json').on('change', gulp.series(resetPages, pages, inline, browser.reload));

See also https://github.com/zurb/panini

另请参见https://github.com/zurb/panini

Good luck!

祝你好运!

#1


2  

Most likely there the src/data directory is missing in the gulpfile.babel.js around line 50.

很可能在第50行的gulpfile.babel.js中缺少src / data目录。

.pipe(panini({
      root: 'src/pages',
      layouts: 'src/layouts',
      partials: 'src/partials',
      helpers: 'src/helpers',
      data: 'src/data'

If you want the browser reload function to work you should also add a watch expression with the others (around ln:106):

如果您希望浏览器重新加载功能正常工作,您还应该与其他人一起添加监视表达式(在ln:106附近):

gulp.watch('src/data/**/*.json').on('change', gulp.series(resetPages, pages, inline, browser.reload));

See also https://github.com/zurb/panini

另请参见https://github.com/zurb/panini

Good luck!

祝你好运!