New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose moment in Demandware environment #1034

Closed
intel352 opened this Issue Aug 29, 2013 · 7 comments

Comments

Projects
None yet
4 participants
@intel352

intel352 commented Aug 29, 2013

I'm working on a site built using Demandware (hosted ecommerce platform). Demandware is built on Java, and has Rhino included for scripting. ES4th edition proposal is supported with JS 1.7, but there seem to be limitations/bugs in some of the native ES functionality. Scripts are given the extension .ds, variables are not exported (only functions).

To get Moment working within Demandware, I renamed the file to Moment.ds, and added the following to the top of the file:

// Function to make Moment available
var moment;
function getMoment() {
    return moment;
}

Then in any script that includes Moment.ds, I have to add var moment = getMoment();.

If you could add this information somewhere, or somehow use it to further expose Moment for closed environments such as Demandware, that would be excellent.

@icambron

This comment has been minimized.

Show comment
Hide comment
@icambron

icambron Sep 27, 2013

Member

Huh. I've never heard of Demandware, but I guess I don't understand the issue exactly. Why can Moment.ds find moment, but other files can't?

Member

icambron commented Sep 27, 2013

Huh. I've never heard of Demandware, but I guess I don't understand the issue exactly. Why can Moment.ds find moment, but other files can't?

@chall8908

This comment has been minimized.

Show comment
Hide comment
@chall8908

chall8908 Sep 28, 2013

I've run into references to this particular platform before, I think. The issue is that, to Demandware, moment is a variable, not a function, and only "global" functions are visible outside a particular file.

Though, I'm a little curious why Demandware can't tell that a variable assigned a function ( var foo = function() {}) and a variable created as a function (function foo() {}) are (mostly) the same thing.

chall8908 commented Sep 28, 2013

I've run into references to this particular platform before, I think. The issue is that, to Demandware, moment is a variable, not a function, and only "global" functions are visible outside a particular file.

Though, I'm a little curious why Demandware can't tell that a variable assigned a function ( var foo = function() {}) and a variable created as a function (function foo() {}) are (mostly) the same thing.

@icambron

This comment has been minimized.

Show comment
Hide comment
@icambron

icambron Oct 4, 2013

Member

I linked to this issue from the docs: http://momentjs.com/docs/#/use-it/other/

Member

icambron commented Oct 4, 2013

I linked to this issue from the docs: http://momentjs.com/docs/#/use-it/other/

@icambron icambron closed this Oct 4, 2013

@kumarharsh

This comment has been minimized.

Show comment
Hide comment
@kumarharsh

kumarharsh Oct 11, 2013

docs? what docs? localhost?

kumarharsh commented Oct 11, 2013

docs? what docs? localhost?

@chall8908

This comment has been minimized.

Show comment
Hide comment
@icambron

This comment has been minimized.

Show comment
Hide comment
@icambron

icambron Oct 11, 2013

Member

Sorry, edited

Member

icambron commented Oct 11, 2013

Sorry, edited

@kumarharsh

This comment has been minimized.

Show comment
Hide comment
@kumarharsh

kumarharsh Oct 12, 2013

sorry... on second reading, i sounded like an idiot :(
no offence intended.

This is the first time outside of a company of a friend of mine that I'm even hearing the name of demandware though :)

kumarharsh commented Oct 12, 2013

sorry... on second reading, i sounded like an idiot :(
no offence intended.

This is the first time outside of a company of a friend of mine that I'm even hearing the name of demandware though :)

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