You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have had trouble trying to get @foreach to work. Nearly every variation I try seems to return the error.
From what I can tell, this seems to be caused by @foreach assuming the array/object has been stringified before being passed to it. If a array/object is passed normally, it fails when trying to do a .match().
The README makes no mention that this needs to be done beforehand either...
Example:
var pp = require('preprocess'),
input = "<!-- @foreach $ITEM in LIST -->$ITEM<!-- @endfor -->";
pp.preprocess(input, {LIST: ['a', 'b', 'c'].toString()}); //returns abc
pp.preprocess(input, {LIST: ['a', 'b', 'c']}); //returns error || TypeError: undefined is not a function
The text was updated successfully, but these errors were encountered:
This is more if an issue with the way preprocess handles variables.
Preprocess was designed to work with environment variables - every value is assumed to be a string. It does not handle raw JS data types currently, as you could not store one in an environment variable - you would need to store the stringified version to reference.
This could be fixed, but would need to think how it fits in with the rest of the intended function.
Have had trouble trying to get
@foreach
to work. Nearly every variation I try seems to return the error.From what I can tell, this seems to be caused by
@foreach
assuming the array/object has been stringified before being passed to it. If a array/object is passed normally, it fails when trying to do a .match().The README makes no mention that this needs to be done beforehand either...
Example:
The text was updated successfully, but these errors were encountered: