Formatting dates with filters
Sometimes you need a slightly more powerful filter than a basic one. You have to use similar filters many times, but every time with a slight variation. Having too many filters can create confusion. This example with dates will illustrate the problem and the solution.
Getting ready
Before moving ahead, make yourself more comfortable with filters by going through the Formatting your text with filters recipe in Chapter 1, Getting started with Vue.js ; if you already know filters, keep reading.
How to do it...
Let's say we are curating an interactive page to learn history. We have our Vue instance with the following JavaScript code:
new Vue({ el:'#app', data: { bastilleStormingDate: '1789-07-14 17 h' } })
In our data, we have a date written informally as a string in our instance data. Our HTML can contain a timeline of the French Revolution and, at some point, can contain the following:
<div id="app"> The Storming of the Bastille, happened on ...