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
I'm writing a personal project using Node.JS and use preprocess to generate HTML from templates. For the most part, I'm very pleased with how this has turned out: I can generate my entire website with a single grunt command. However, one issue has come up time and time again: for loops really aren't that useful.
One of my pages generates a link to each of my projects, using a styled HTML list, like this:
But I think you can already spot the problem: I need a parameter for both the link and the project title and I can only ever have one. There are no string splitting functions in the syntax, so I can't even hack in a second parameter by splitting a string on a predetermined character. So I end up writing code like this:
This works, but this basically means the @foreach has no use for my project. In my opinion, the loop could be more useful if it supported syntax like this:
In order to keep the syntax sane and prevent the module from growing into a full-blown scripting language, I would add the requirement that the iterated values can only be strings or numbers, not lists or objects.
The text was updated successfully, but these errors were encountered:
I'm writing a personal project using Node.JS and use
preprocess
to generate HTML from templates. For the most part, I'm very pleased with how this has turned out: I can generate my entire website with a singlegrunt
command. However, one issue has come up time and time again: for loops really aren't that useful.One of my pages generates a link to each of my projects, using a styled HTML list, like this:
The problem is that I cannot generate this list using
preprocess
. I can wrap the block in a@foreach
loop, like so:But I think you can already spot the problem: I need a parameter for both the link and the project title and I can only ever have one. There are no string splitting functions in the syntax, so I can't even hack in a second parameter by splitting a string on a predetermined character. So I end up writing code like this:
This works, but this basically means the
@foreach
has no use for my project. In my opinion, the loop could be more useful if it supported syntax like this:In order to keep the syntax sane and prevent the module from growing into a full-blown scripting language, I would add the requirement that the iterated values can only be strings or numbers, not lists or objects.
The text was updated successfully, but these errors were encountered: