Workaround for accessing window global? (command line compiler)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Workaround for accessing window global? (command line compiler)

Hannes Hirzel
Hello

I am compiling on the command line with grunt an app which is client
side and uses

     initialize
        storage := localStorage.


The compiler error message is

    $ grunt
    Running "amberc:all" (amberc) task
    Reading: src/TodoList.st
    [Error: Compiler error in section:
    TodoStorage methodsFor: 'initializing'

    while processing chunk:
    initialize
    storage := localStorage.
    array := self getArray.

    Unknown Variable error: localStorage is not defined]

    Done, without errors.


What is the workaround to access the window global variable
     localstorage
so that the command line compiler compiles the code?

Thank you in advance

--Hannes

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Workaround for accessing window global? (command line compiler)

Herby Vojčík
There's a grunt option to the amberc task the allow to specify additional known globals. See Amber's own Gruntfile.js for an example (there, IIRC, 'navigator' was added in this manner).

H. Hirzel wrote:

> Hello
>
> I am compiling on the command line with grunt an app which is client
> side and uses
>
>       initialize
> storage := localStorage.
>
>
> The compiler error message is
>
>      $ grunt
>      Running "amberc:all" (amberc) task
>      Reading: src/TodoList.st
>      [Error: Compiler error in section:
>      TodoStorage methodsFor: 'initializing'
>
>      while processing chunk:
>      initialize
>       storage := localStorage.
>       array := self getArray.
>
>      Unknown Variable error: localStorage is not defined]
>
>      Done, without errors.
>
>
> What is the workaround to access the window global variable
>       localstorage
> so that the command line compiler compiles the code?
>
> Thank you in advance
>
> --Hannes
>

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.