Handlebars with Express.js - Should I transform raw data in templates or elsewhere?

185 Views Asked by At

I'm going to make a web app using Express, and Handlebars seems to be a good templating engine choice, but I wonder where raw JSON data should be made human-readable: in the templates or in actual JS code?

Let's say I have this piece of JSON:

{
  raw_item_name: "Whatever",
  item_quality: 2
}

item_quality could represent "Unusual". The human-readable version of this JSON would be "Unusual Whatever", and that's what I want the end user to see on the page. My question is, should I pass this JSON directly to the template and use helpers to transform it, or transform it elsewhere and pass the final string to the template to have it directly display it?

0

There are 0 best solutions below