Skip to content
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
Closed

Expose moment in Demandware environment #1034

intel352 opened this issue Aug 29, 2013 · 7 comments
Labels

Comments

@intel352
Copy link

@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
Copy link
Member

@icambron 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
Copy link

@chall8908 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
Copy link
Member

@icambron 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
Copy link
Contributor

@kumarharsh kumarharsh commented Oct 11, 2013

docs? what docs? localhost?

@icambron
Copy link
Member

@icambron icambron commented Oct 11, 2013

Sorry, edited

@kumarharsh
Copy link
Contributor

@kumarharsh 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.