i am trying to build a page with templates, where i am setting some parameters. Inside the main template this works perfect:
<!-- build:process -->
<%= variable %>
<!-- /build -->
is correctly replaced by:
Value
To write the header only once, i have it in a separate file and include it as section, which works fine.
<!-- build:section header -->
<!-- /build -->
But the variables inside the header section are not processed and the partial template is included as it is:
<!-- build:process -->
<%= variable %>
<!-- /build -->
What am i doing wrong here? Do i need to configure something so the sections are also processed?
Thx
It looks like a bug in the grunt-html-build
module.
The only quick decent solution I can propose is to process header separately to temporary file:
var grunt = require('grunt')
grunt.loadNpmTasks('grunt-html-build')
grunt.initConfig({
htmlbuild: {
header: {
src: 'head.html',
dest: 'temp/head.html', // << write processed header to temp file
options: {
data: {
variable: "Value"
}
}
},
dist: {
src: 'body.html',
dest: 'build/',
options: {
sections: {
header: 'temp/head.html' // << read processed header
}
}
}
}
});