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

Comments

@intel352
Copy link

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

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

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 commented Oct 4, 2013

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

@icambron icambron closed this as completed Oct 4, 2013
@kumarharsh
Copy link
Contributor

docs? what docs? localhost?

@chall8908
Copy link

@icambron
Copy link
Member

Sorry, edited

@kumarharsh
Copy link
Contributor

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
Development

No branches or pull requests

4 participants