Mikhail
Mikhail

Reputation: 9007

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.

Upvotes: 2

Views: 883

Answers (1)

Paul Armstrong
Paul Armstrong

Reputation: 7156

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.

Upvotes: 1

Related Questions