preprocess
preprocess copied to clipboard
Include with a variable?
Is there an option to put a variable in an include?
<!-- @if BLAH -->
<!-- @include BLAH/file.html -->
<!-- @endif -->
Tried also
<!-- @include $BLAH/file.html -->
But it doesn't replace the variable, so it doesn't find the file.
No, not at the moment. As a workaround, you could try to combine this with @foreach
in the following manner:
<!-- @if BLAH -->
<!-- @foreach $BLAH in ['somefile'] -->
<!-- @include $BLAH/file.html -->
<!-- @endfor -->
<!-- @endif -->
But I have no idea whether it will work or not.
Thanks. I just used gulp-replace
for now to replace specific variables before preprocess. Does the job.
Can I close this or is this a feature request?
I think it'd be a good addition to preprocess, replacing $VAR
or ${VAR}
with the value before handing @include
.
We'll see what we can do :-)
was tis ever implemented?
Would be a good addition.
Preprocess context:
context: {
test: 'hello-world'
}
File to preprocess:
// @include-static ${test}.js
console.log(1);
So that @include-static ${test}.js
is @include-static hello-world.js
No ability to use a variable with @include still? I was hoping to generate html files from a common template using this by passing the @include file in via context.