Search code examples
node.jsexpressswig-template

NodeJS Swig math


I'm completely baffled by swig templating in node. How do I subtract two values?

Neither of the following works:

{{ stop - start }}
{{ stop|add(-start) }}

I ended up having to compute this in the view and pass it in. Is that the only way? I guess I could write my own subtract filter, but that seems like a bad solution.


Solution

  • For now, you'll have to write a custom filter.

    In the next version of Swig, which is undergoing a full rewrite, you'll be able to use simple operators in variables.