My problem is the following: I'm trying to refactor a website and to replace all strings into some variables so when I change a variable it changes across the whole website. However, here comes the issue:
I have data in multiple Json files and I get it like so with gulp:
var locals = {
// Content
someContent: require('../data/content-path.json'),
someOtherContent: require('../data/other-content-path.json'),
};
gulp.task('jade:pages', function() {
return gulp.src(pages)
.pipe(plumber())
.pipe(jade({
locals: locals
})
.on('error', notify.onError({
title: 'Jade Error',
message: '<%= error.message %>'
})))
.pipe(gulp.dest('dist'));
});
So I can easily access any key from Jade like so #{someContent.key1}.
However, if I want to use some key from my someContent in my someOtherContent it renders it as a string (not parsing a variable).
someContent
{
"key1" : {
"subkey1": "5",
"subkey2": "9"
},
"key2":"<p>Some markup which parsed as html if desirable</p>",
}
someOtherContent
{
"title": "#{someContent.key1.subkey1} some other text"
}
So it works perfectly if I just use it directly in Jade, but it can't parse such a reference if I use it as #{someOtherContent.title}, and it outputs exactly
"#{someContent.key1.subkey1} some other text"
when I want it to output this instead
"5 some other text"
What could I do here to make it work? Any help is really appreciated. Thank you everyone.