docpad-plugin-moment

2.0.2 • Public • Published

DocPad Moment Plugin

Use the Moment module to format specified dates.

Getting Started

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>

Future

  • Provide a generic templateHelper for on-the-fly formatting
  • Maybe incorporate some of the other functionality of Moment.js?

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.2
    1
  • 2.0.1
    0
  • 2.0.0
    0

Package Sidebar

Install

npm i docpad-plugin-moment

Weekly Downloads

1

Version

2.0.2

License

MIT

Last publish

Collaborators

  • brockfanning