Skip to content

Commit

Permalink
Update Moment.js to version 2.27.0 and add option to use Moment.js wi…
Browse files Browse the repository at this point in the history
…thout locales (#63)
  • Loading branch information
sgraaf committed Aug 12, 2020
1 parent 677a6f1 commit 5472239
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions flask_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
default_jquery_sri = ('sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn'
'/6Z/hRTt8+pR6L4N2')

# //cdnjs.cloudflare.com/ajax/libs/moment.js/2.26.0/moment-with-locales.min.js
default_moment_version = '2.26.0'
default_moment_sri = ('sha384-WxkyfzCCre+H1hXpoMH2JOqSotIuNoiH5KQ4zCQxIxOSHo4'
'9PeKFlgftAkREuLTR')
# //cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment-with-locales.min.js
default_moment_version = '2.27.0'
default_moment_sri = ('sha512-rmZcZsyhe0/MAjquhTgiUcb4d9knaFc7b5xAfju483gbEXT'
'keJRUMIPk6s3ySZMYUHEcjKbjLjyddGWMrNEvZg==')


class _moment(object):
@staticmethod
def include_moment(version=default_moment_version, local_js=None,
no_js=None, sri=None):
no_js=None, sri=None, with_locales=True):
js = ''
if version == default_moment_version and local_js is None and \
sri is None:
Expand All @@ -31,9 +31,13 @@ def include_moment(version=default_moment_version, local_js=None,
'crossorigin="anonymous"></script>\n').format(
local_js, sri)
elif version is not None:
js_filename = 'moment-with-locales.min.js' \
if StrictVersion(version) >= StrictVersion('2.8.0') \
else 'moment-with-langs.min.js'
if with_locales:
js_filename = 'moment-with-locales.min.js' \
if StrictVersion(version) >= StrictVersion('2.8.0') \
else 'moment-with-langs.min.js'
else:
js_filename = 'moment.min.js'

if not sri:
js = ('<script src="//cdnjs.cloudflare.com/ajax/libs/'
'moment.js/{}/{}"></script>\n').format(
Expand Down

0 comments on commit 5472239

Please sign in to comment.