Getting json data to build templates in grunt

I use assembly ( https://github.com/assemble/assemble ) through the grunt plugin to create static pages.

I have been using grunt for a while, so I understand how it all works, but this is my first time I put together the assembly, so I looked at this for ref ( http://blog.parkji.co.uk/2013/07 /06/building-a-static-site-using-grunt-and-assemble.html ). Everything seemed to be working fine.

However, I want to submit JSON data to the mix and looked at the documents on the assembly site ( http://assemble.io/docs/Data.html ) even after I run "grunt assembly", it does not display json data :(

My grunt file

 assemble: {
        options: {
            layout: "src/responsive/layouts/default.hbs",
            data: 'src/responsive/data/**/*.json',
            flatten: true
        },
        pages: {
            files: {
                'src/': ['src/responsive/pages/*.hbs']
            }
        }
    },

test json:

{
  "name ": "This is a square widget" ,
  "modifier ": "widget-square" 
 }

and folder structure:

- data
-- index.json
- layouts
-- default.hbs
- pages
-- index.hbs

pages/index.hbs {{index.name}} {{name}} ( ) .

Im ( , json grunt , ).

, .

,

+4
1

JSON . keys. JSON :

{
  "name": "This is a square widget",
  "modifier": "widget-square" 
}
+4

Source: https://habr.com/ru/post/1541136/


All Articles