Create a gist now

Instantly share code, notes, and snippets.

@balupton /README.md
Last active Oct 13, 2015

Embed
What would you like to do?
DocPad: Localising Dates
# 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
This document was last modified at: <%= @formatDate(@document.date) %>
@dcardosods

This comment has been minimized.

Show comment
Hide comment
@dcardosods

dcardosods Mar 28, 2013

To works fine is necessary the follow update in docpad.coffe

# Requires
moment = require('moment')
moment.lang('fr')  # set locale to french

dcardosods commented Mar 28, 2013

To works fine is necessary the follow update in docpad.coffe

# Requires
moment = require('moment')
moment.lang('fr')  # set locale to french
@mikeumus

This comment has been minimized.

Show comment
Hide comment
@mikeumus

mikeumus Apr 12, 2013

I'm getting this when I try it:

error: An error occured:
TypeError: undefined is not a function
    at Object.docpadConfig.templateData.formatDate

on DocPad@6.30.3

mikeumus commented Apr 12, 2013

I'm getting this when I try it:

error: An error occured:
TypeError: undefined is not a function
    at Object.docpadConfig.templateData.formatDate

on DocPad@6.30.3

@fizzvr

This comment has been minimized.

Show comment
Hide comment
@fizzvr

fizzvr Apr 13, 2013

in JS

var docpadConfig,moment;
moment = require('moment');
moment.lang('es');

docpadConfig = {
  templateData: {
formatDate: function(date, format) {
  if (format == null) {
format = 'LLLL';
  }
  return moment(date).format(format);
}
  }
};
module.exports = docpadConfig;

fizzvr commented Apr 13, 2013

in JS

var docpadConfig,moment;
moment = require('moment');
moment.lang('es');

docpadConfig = {
  templateData: {
formatDate: function(date, format) {
  if (format == null) {
format = 'LLLL';
  }
  return moment(date).format(format);
}
  }
};
module.exports = docpadConfig;
@zenorocha

This comment has been minimized.

Show comment
Hide comment

zenorocha commented Nov 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment