Docs

Everything You Need to Know

Data Formatting

Intro

Truck Chassis

Data is king. Data is the one source of truth in your app. But data needs to be presented in a manner so that users can understand what they are seeing. Truck provides methods to help you format your data.

  • formatNumber
  • sum
  • currency
  • formatTime
  • sortDate
  • sortNumbers
  • sortNumbersDescending

You use these in a template to format the data being rendered by the view:

<script type="text/x-template">
  <li>
    <h3>Item: ${ data.name }, Price: { $.currency(data.price) }</h3>
  </li>
</script>