Git Product home page Git Product logo

handlebars-helper-moment's People

Contributors

arkkimaagi avatar doowb avatar idpaterson avatar jonschlinkert avatar tobias74 avatar zeropaper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

handlebars-helper-moment's Issues

Conditional helper

It would be awesome to make some momentJS conditional helper.

For insctance:

{{moment-if currentDate is today}} Happy birthday {{/moment-if}}

Unable to include it to assemble

npm i line doesn't work. I need to run
npm i handlebars-helper-momentjs --save-dev to get the helper & I'm not sure this is correct because I wasn't able to include the helper.
I tried a lot of various stuff like this

helpers: ['helper-moment'], // Warning: Could not find property 'moment'
helpers: ['helper-momentjs'], // Warning: Could not find property 'moment'
helpers: ['handlebars-helper-momentjs'], // Warning: Could not find property 'moment'
helpers: ['handlebars-helper-*'], // Warning: Could not find property 'moment'
helpers: ["<%= _.load('handlebars-helper-*') %>"], // Warning: must provide pattern

I also try hardcoded path didn't work neither. What am I missing ?

Incorrect date format returned for 30th of the month when passing format 'Mon 30, XXXX' - Stencil

Description

{{moment}} returns incorrect format/characters in Stencil when passing a date on the 30th of a month formatted such as Nov 30, 2021.
{{moment "Nov 30, 2021}} will return ADov 30, 2021
This results in {{moment "Nov 30, 2021" "YYYYMMDD"}} returning Invalid date
This may not only apply to Stencil - I have not tested in other contexts.

Replication

  1. In a Stencil context template with {{moment}} library, add the following:
    <div>{{moment "Nov 30, 2021}}</div>
  2. Render this template in browser.

Expected Results

Nov 30, 2021 is displayed on the page.

Actual Results

ADov 30, 2021 is displayed.

Workaround

Use momentjs directly.

Timezone support?

are there any plans to support the (new) moment-timezone? This would allow formatting dates to a certain timezone via the tz()-method

Blockhelper

I would expect for {{#moment format="MMMM YYYY"}}2026-04-04{{/moment}} an output like April 2026. But I get April 2016 (current date). If the blockhelper would work, I could do something like:

{{#moment format="MMMM YYYY"}}{{myHelper year}}{{/moment}}

What do you think?

Trouble Adding Days to Date

Given date = 2020-04-23T14:09:00.977 The below code both output the same result,

{{moment date format="MM/DD/YYYY"}}
{{moment date add="{day:20}" format="MM/DD/YYYY"}}

// 04/23/2020 
// 04/23/2020 

I'm essentially looking to see if a specific date was less than 20 days ago.

{{#if (moment "now" format="MM/DD/YYYY") ">=" (moment date add="{days:20}" format="MM/DD/YYYY") }}
// do something
{{/if}}

I know there's the from function: {{moment from=date}} but that returns a string "in 19 days" and not a number.

Maybe I'm just missing a function or something but I could really use some help here.

Thanks!

helper docs

@Arkkimaagi I finally got the helper updated and documentation up for them. sorry it took so long.

Do you mind if I add the documentation for this to the assemble site? Or would you even want to move it to assemble, and of course stay as the maintainer of it? It might be more likely to be seen and used. but that's entirely up to you.

either way, this is an awesome helper, you did a really amazing job on this

Use without Assemble?

Is it possible to use this without assemble and just register the helpers with handlebars like handlebars.registerHelper('moment', require('handlebars-helper-moment'));

I have tried doing this but it did not work. Am I doing something wrong or is this not possible?

UTC doesn't work

Hi,

This code doesn't work
{{moment example UTC=null format="dddd, DD MMMM YYYY HH:mm:ss ZZ"}}

UTC=null change nothing

Date Manipulation

Hi Jon, nice work on the helpers. We use them extensively and love it.

I'm having trouble figuring out how to use the moment.js add manipulation. In your example I can see you're referencing some YAML, which I am unfamiliar with, but it looks like a json object declaration.

I tried this {{moment item.eventDate add=hours.one format="h:mm A"}}

But I always get this error. {"code":"InternalError","message":"Cannot read property 'years' of undefined"}

I realize this problem is probably related to the context, and perhaps the context that the helper is running in isn't aware of the hours.one variable I've declared. Where should I declare these variables to make it available for the helper?

The context I'm running this is a node.js REST service, not using assemble.io/grunt

I am wondering also if it possible to pass an object notation in a string. For example, {{moment item.eventDate add={hours:7} format="h:mm A"}}

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.