New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Appending to a list #240
Comments
|
You might want to take a look at nunjucks-append to see how this could be implemented with nunjucks. |
|
@sbruchmann Thanks for the pointer; looks a bit out of scope -- but I'll have a closer look. |
|
Did you try push()? They're just JavaScript arrays
|
|
@mattbasta Excuse my inexperience, but how would I call push() from a block within a template? Are you perhaps suggesting that I should declare the variable and pass it to the template while rendering? |
|
No. There is no |
|
Sorry, should've been closed a while ago. |
|
In what context should I use push? I want to do the same thing. However when I do: I'm seeing what looks like an index outputted? |
That's because you're calling the native array |
|
Thanks for the quick reply @jlongster. That makes sense, I didn't want to do it in the templates either, I was doing it as a quick fix because I'm waiting for a fellow developer to write the filter. |
|
Ok. For now just put that expression at the top-level of your template and use |
|
|
@rambo-panda |
I'm trying to append to a list. Jinja2 docs suggest a similar pattern:
Neither
donorlist.append()seems to exist in nunjucks.The text was updated successfully, but these errors were encountered: