Skip to content

Instantly share code, notes, and snippets.

@balupton
Last active October 13, 2015 08:18

Revisions

  1. balupton revised this gist Jan 2, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,6 @@

    2. Add it and a template helper to your [docpad configuration file](http://bevry.me/docpad/config)

    3. Use the template helper in your app
    3. Use the template helper in your app

    [Discussion about localisation within DocPad.](https://github.com/bevry/docpad/issues/17)
  2. balupton revised this gist Jan 2, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # DocPad: Localising Dates

    1. Install [Moment](http://momentjs.com) via `npm install --save moment`

    2. Add it and a template helper to your [docpad configuration file](http://bevry.me/docpad/config)
  3. balupton created this gist Nov 29, 2012.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1. Install [Moment](http://momentjs.com) via `npm install --save moment`

    2. Add it and a template helper to your [docpad configuration file](http://bevry.me/docpad/config)

    3. Use the template helper in your app
    11 changes: 11 additions & 0 deletions docpad.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # Requires
    moment = require('moment').lang('fr') # set locale to french

    # Define Configuration
    docpadConfig =
    templateData:
    # Format the passed date, by default format like: Thursday, November 29 2012 3:53 PM
    formatDate: (date,format='LLLL') -> return moment(date).format(format)

    # Export Configuration
    module.exports = docpadConfig
    1 change: 1 addition & 0 deletions my-document.html.eco
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    This document was last modified at: <%= @formatDate(@document.date) %>