Let's say I have a simple collection of product_orders in Meteor (_id, user_id, user_name, product_name, price_unit, quantity), and I want to show all the orders of one user in the table, where each row should contain:
user_name, product_name, quantity, price_unit, quantity, price_total (price_unit * quantity)
In addition, I would like to show the total amount for all custom orders.
I see no easy way to do this in the Handlebars.js template, because Handlebars does not support simple math operations. I can easily return the product_order cursor to my template, but I donβt see a simple way to calculate price_total and the total in the template.
I am thinking of creating a template helper, but not sure if this is the right direction. This problem looks as if it should have a simple and elegant solution.
source share