{{ }} has trouble with method calls and array indexes in single call
In a forum app I am working on, I have found that this works (in a template):
{% set lastpost=thread.dataValues.Comments[latest] %}
Last post on {{ lastpost.datetime.toLocaleString() }}
However, if I try to combine it into one line, like so:
{{ thread.dataValues.Comments[latest].datetime.toLocaleString() }}
it results in
TypeError: Method invoked on an object that is not Date. at toLocaleString (native) at eval (eval at <anonymous> (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:498:13), <anonymous>:79:2009) at Object.exports.each (/home/ubuntu/workspace/node_modules/swig/lib/utils.js:45:11) at eval (eval at <anonymous> (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:498:13), <anonymous>:50:10) at Object.eval [as tpl] (eval at <anonymous> (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:498:13), <anonymous>:95:3) at compiled (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:619:18) at /home/ubuntu/workspace/node_modules/swig/lib/swig.js:559:20 at /home/ubuntu/workspace/node_modules/swig/lib/swig.js:690:9 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Additionally, attempting to do
{{ typeof(thread.dataValues.Comments[latest].datetime) }}
results in
Error: SyntaxError: Unexpected token !== in file /home/ubuntu/workspace/static/topic.html. at Object.exports.throwError (/home/ubuntu/workspace/node_modules/swig/lib/utils.js:183:9) at precompile (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:505:13) at compile (/home/ubuntu/workspace/node_modules/swig/lib/swig.js:606:16) at /home/ubuntu/workspace/node_modules/swig/lib/swig.js:684:27 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
thats javascript errors, those are not at all related to flask (which is python)
at first glance there seems to be an accidential mix between clientside code and serverside code please provide extra context
Please use Stack Overflow for questions about your own code. Read how to create a minimal, complete, and verifiable example first.
Oops, accidentally put this in the wrong repository, should have been on Swig's repo, not flask's. Sorry for the confusion.