Adds support for date formatting with Moment.js
- Use:
require('docpad-plugin-moment')
- Install:
npm install --save docpad-plugin-moment
Configure some formats in your docpad.coffee
:
plugins:
moment:
formats: [
{raw: 'date', format: 'MMMM Do YYYY', formatted: 'humanDate'}
{raw: 'date', format: 'YYYY-MM-DD', formatted: 'computerDate'}
]
- raw = the name of the existing attribute in your content
- format = the format you want it changed to
- formatted = a name for the new version
Then, in your template, instead of:
<span>Posted on <%- @date %></span>
You would do:
<span>Posted on <%- @humanDate %></span>
To do anything else that the Moment.js library allows, you can access Moment using the @moment()
helper. For example,
<span><%= @moment('2013-10-13').format('MMMM Do YYYY') %></span>
...would output...
<span>October 13th 2013</span>
Discover the change history by heading on over to the HISTORY.md
file.
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
These amazing people are maintaining this project:
- Brock Fanning brockfanning@gmail.com (http://brockfanning.com)
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Licensed under the incredibly permissive MIT license
Copyright © 2013+ Brock Fanning brockfanning@gmail.com (http://brockfanning.com)