Bonjour,

Je suis en train de mettre en place un gruntfile.js me permettant de compiler du css et du html avec sass et twig.

Tout fonctionne sauf lorsque j'essaye de gérer mes twig sous forme de composant.
Dans l'idée j'ai un fichier JSON par page et d'autre fichier json pour chaque composants de la page (carousel, navigation, footer etc) je voudrait appeler ces fichier json de composant au sein de mes json de page

J'ai essayer de faire ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
{
    "page_title": "homepage",
    "layout": "layout/one_col.twig",
    "nav": {
    	"../../data/components/navigation.json": {
		}
    }
}
Mais lors de mon twig render j'obtient une erreur EISDIR.

Pouvez vous me dire comment intégrer mes JSon composant dans mes JSon de page?

Voici mon gruntfile.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
 
module.exports = function(grunt) {
	// Configurable paths
	var path = require('path'), 
	config = {
		app: 'app',
		dist: 'dist',
		temp: '.tmp',
		twig: grunt.option('twig') || '*',
		pkg: grunt.file.readJSON('package.json')
	};
 
	/*add specific files for twig compilation
	 * grunt --twig='page1,page2,page3...'
	 * or for all page
	 * grunt
	 */
	if(grunt.option('twig')){
		var twigPageArray = config.twig.split(','),
			twigPageArrayNb = twigPageArray.length,
			i;	
		for(i=0; i<=twigPageArrayNb; i++){
			if(typeof twigPageArray[i] != 'undefined'){
				var page = twigPageArray[i]+'.json';
				twigPageArray[i] = page;
			}
		}
		config.twig = twigPageArray;
	}else {
		config.twig = ['*'];
	}
 
 
	// Time how long tasks take. Can help when optimizing build times
	require('time-grunt')(grunt);
 
	// Show options.
	grunt.log.write('Twig option : ' + config.twig);
 
    require('lazy-load-grunt-config')(grunt, {
        // Path to task files, defaults to grunt dir. 
        configPath: path.join(process.cwd(), 'grunt'),
 
        // Auto grunt.initConfig 
        init: true,
 
        // Data passed into config. Can use with <%= test %> 
        data: {
            test: false
        },
 
        // Can optionally pass options to load-grunt-tasks. If you set to false, it will disable auto loading tasks. 
        loadGruntTasks: {
            pattern: 'grunt-*',
            config: config.pkg,
            scope: 'devDependencies'
        }
    });	
 
	// Project configuration.
	grunt.initConfig({
		// Project settings
		config: config,
 
 
		// Watches files for changes and runs tasks based on the changed files
		watch: {
			sass: {
				files: ['<%= config.app %>/scss/**/*.{scss,sass}'],
				tasks: ['styles'],
				options: {
					/*speeds up the reaction time of the watch
					https://www.npmjs.com/package/grunt-contrib-watch#options-spawn*/
					spawn: false
				}
			},
			twig: {
				files: ['<%= config.app %>/twig/**/*.{twig,tpl}'],
				tasks: ['twigRender']
			},
			data: {
				files: ['<%= config.app %>/data/{,*/}*.json'],
				tasks: ['twigRender']
			},
			scripts: {
				files: ['<%= config.app %>/js/{,*/}*.js'],
				tasks: ['jshint']
			}
		},
 
		// BrowserSync
		browserSync: {
			dev: {
				bsFiles: {
					src : ['<%= config.app %>/css/*.css','<%= config.app %>/pages/*.html']
				},
				options: {
					watchTask: true,
					server: '<%= config.app %>'
				}
			}
		},
 
		// Add vendor prefixed styles and minified css
		postcss: {
			options: {
				// inline sourcemaps
				map: true ,
				processors: [
					// add vendor prefixes
					require('autoprefixer')({browsers: 'last 2 versions'}),
					// minified of media query styles
					require('css-mqpacker')(),
					// minify the result 
					require('cssnano')()
				]
			},
			dist: {
				src: '<%= config.temp %>/css/*.css'
			}
		},
 
		// Empties folders to start fresh
		clean: {
			dist: {
				files: [{
					dot: true,
					src: ['<%= config.temp %>','<%= config.dist %>/*']
				}]
			}
		},
 
		//Concat and minified JS files
		uglify: {
			options: {
				mangle: false	
			},
			dist: {
				files: {
					'<%= config.app %>/js/cv.min.js': ['<%= config.app %>/js/vendor/jquery-1.11.3.min.js', '<%= config.app %>/js/plugins/*.js','<%= config.app %>/js/cv.*.js', '!<%= config.app %>/js/cv.min.js' ]
				}
			}
		},
 
		// TwigRender
		twigRender: {
			dist: {
				files : [
					{
						template: '<%= config.app %>/twig/template.twig',
						expand: true,
						cwd: '<%= config.app %>/data/',
						src: '<%= config.twig %>', // post1.json, post2.json,... 
						dest: '<%= config.app %>/pages/',
						ext: '.html'   // post1.json + template.twig => post1.html 
					}
				]
			},
		},
 
		// Copies remaining files to places other tasks can use
		copy: {
			css: {
				expand: true,
				dot: true,
				cwd: '<%= config.temp %>/css/',
				dest: config.app + '/css',
				src: '**/*.css'
			}
		},
 
		// Make sure code styles are up to par and there are no obvious mistakes
		jshint: {
			all: ['Gruntfile.js', '<%= config.app %>/js/*.js', '!<%= config.app %>/js/cv.min.js']
		},
 
		// Compiles Sass to CSS and generates necessary files if requested
		sass: {
			dev: {
				files: [{
					expand: true,
					cwd: '<%= config.app %>/scss/template/',
					src: ['*.{scss,sass}'],
					dest: '<%= config.temp %>/css',
					ext: '.css'
				}]
			}
		}
 
 
	});
 
	// List of task for stylesheet
	grunt.registerTask('styles', [
		'sass:dev',
		'postcss',
		'copy:css'
	]);
 
	// List of task for build
	grunt.registerTask('build', [
		'clean',
		'jshint',
		'styles',
		'uglify:dist',
		'twigRender',
		'browserSync',
		'watch'
	]);
 
	// Load default grunt task **grunt**
	grunt.registerTask('default', ['build']);
};
Merci par avance pour votre aide

Orphen