Git Product home page Git Product logo

Comments (6)

jasonmit avatar jasonmit commented on June 16, 2024

There is a bug in ember around parameterless helpers. Once that is resolved I can look into adding this.

from ember-moment.

jcope2013 avatar jcope2013 commented on June 16, 2024

+1, what's your thoughts on a global config like this? it can default to false, I can make a PR if wanted


// addon/utils/compute-fn.js

import Ember from 'ember';
import config from '../config/environment';

export default function(cb) {
  return function(params, hash) {
    if (!params || params && params.length === 0) {
      throw new TypeError('ember-moment: Invalid Number of arguments, expected at least 1');
    }

    let allowEmpty = Ember.get(config, 'moment.allowEmpty');

    const datetime = params[0];

    if(hash.allowEmpty || hash['allow-empty'])
    {
      allowEmpty = hash.allowEmpty || hash['allow-empty'];
    }

    if ([null, '', undefined].indexOf(datetime) > -1 && allowEmpty) {
      Ember.Logger.warn('ember-moment: an empty value (null, undefined, or "") was passed to moment-format');
      return;
    }

    return cb.apply(this, arguments);
  };
}

// config.environment.js
module.exports = function() {
  return {
    moment: {
      allowEmpty: true
    }
  }
};

from ember-moment.

jasonmit avatar jasonmit commented on June 16, 2024

That seems interesting, I'm in favor and would be happy to review your PR. My original interpretation was the OP wanted to just write {{moment-format}} without ever passing an argument. Makes sense to make allow-empty a global setting.

from ember-moment.

mohlek avatar mohlek commented on June 16, 2024

@jasonmit well, at least I want to pass a date :) Even though its null..
@jcope2013 that fix seems to do just what i wanted :) Please PR

from ember-moment.

jasonmit avatar jasonmit commented on June 16, 2024

Thanks @jcope2013

I have some house keeping changes and will version tomorrow.

from ember-moment.

jasonmit avatar jasonmit commented on June 16, 2024

3.6.0 closes this. Thanks again everyone

from ember-moment.

Related Issues (20)

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.