GithubHelp home page GithubHelp logo

nikolaygalkin / docpad-plugin-moment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brockfanning/docpad-plugin-moment

0.0 1.0 0.0 243 KB

Adds support for date formatting with Moment.js

License: MIT License

CoffeeScript 97.02% HTML 2.98%

docpad-plugin-moment's Introduction

DocPad Moment Plugin

Build Status NPM version Dependency Status Development Dependency Status

Adds support for date formatting with Moment.js

Install

  • Use: require('docpad-plugin-moment')
  • Install: npm install --save docpad-plugin-moment

Usage

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>

General use

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>

History

Discover the change history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Licensed under the incredibly permissive MIT license

Copyright ยฉ 2013+ Brock Fanning [email protected] (http://brockfanning.com)

docpad-plugin-moment's People

Contributors

brockfanning avatar pavel-voronin avatar robloach avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.