{
"navigationData": [
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
},
{
"name": "Link for display",
"url": "http://google.com"
},
{
"name": "Looooong long items for test long plain text",
"url": "http://google.com"
}
]
}
let gulp = require('gulp'),
browserSync = require('browser-sync').create(),
autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
cleancss = require('gulp-clean-css'),
jade = require('gulp-jade'),
minify = require('gulp-minify'),
data = require('gulp-data'),
path = require('path'),
fs = require('fs')
...
gulp.task('jade', function(done) {
let LOCALS = {}
gulp.src('app/*.jade')
.pipe(data( function(file) {
return JSON.parse(
fs.readFileSync('./app/data/data.json')
)
}))
.pipe(jade({
locals: LOCALS,
pretty: true
}))
.pipe(gulp.dest('app'))
done()
})
...
nav.navbar-list
- var nav = navigationData
ul
each val in nav
li.navbar-list-item
a(href=val.url)=val.name
events.js:167
throw er; // Unhandled 'error' event
^
TypeError: C:\Users\elliz\OneDrive\Документы\Работа\Тестовые задания\alef\app\index.jade:18
16| - var nav = navigationData
17| ul
> 18| each val in nav
19| li.navbar-list-item
20| a(href=val.url)=val.name
21|
Cannot read property 'length' of undefined
return JSON.parse(
fs.readFileSync('./app/data/data.json')
); <------- ';'
{"navigationData":[{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"},{"name":"Link for display","url":"http://google.com"},{"name":"Looooong long items for test long plain text","url":"http://google.com"}]}