You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Sandro Boehme <sa...@gmx.de> on 2015/10/18 00:04:06 UTC

Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

Hello,

I would like to access the current resource in the Sightly JavaScript 
Use-API. The docu [1] says I should for example use 
"granite.resource.properties["title"];" to access the "title" property 
of the current resource. But of course "granite" is not available in 
Sling. This is why I'm wondering what variable is available in Sling 
instead.

Thanks in advance for any hints,

Sandro

[1] - 
http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html

PS: There is no Sling docu for Sightly yet, right?

Re: Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

Posted by Sandro Boehme <sa...@gmx.de>.
After a fresh checkout and build it works now so everything is fine.

Best,

Sandro

Am 18.10.15 um 12:15 schrieb Sandro Boehme:
> Thanks for your feedback Vlad and Dirk and for your initiative creating
> the Sightly docu Vlad!
>
> Sadly for some reason "properties", "resource" and
> "request.getResource()" return an empty object {}.
>
> Does anyone know what the reason could be?
>
> Best,
>
> Sandro
>
> Am 18.10.15 um 09:55 schrieb Dirk Rudolph:
>> I think you can use something like this:
>>
>> "use strict"
>>
>> var resource = this.request.getResource()
>>
>>
>> use(function() { ... });
>>
>>
>> Cheers, Dirk
>>
>>
>> On Sunday, 18 October 2015, Vlad Bailescu <vl...@bailescu.ro> wrote:
>>
>>> Hi Sandro,
>>>
>>> I started putting together some documentation at [2] but it's stil WIP.
>>>
>>> Vlad
>>>
>>> [2] -
>>> https://github.com/vladbailescu/sling-sightly-docs/blob/master/use-api.md
>>>
>>>
>>>
>>> On Sunday, October 18, 2015, Sandro Boehme <sandro.boehme@gmx.de
>>> <javascript:;>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I would like to access the current resource in the Sightly JavaScript
>>>> Use-API. The docu [1] says I should for example use
>>>> "granite.resource.properties["title"];" to access the "title"
>>>> property of
>>>> the current resource. But of course "granite" is not available in
>>>> Sling.
>>>> This is why I'm wondering what variable is available in Sling instead.
>>>>
>>>> Thanks in advance for any hints,
>>>>
>>>> Sandro
>>>>
>>>> [1] -
>>>>
>>> http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html
>>>
>>>>
>>>> PS: There is no Sling docu for Sightly yet, right?
>>>>
>>>
>>>
>>> --
>>> Sent from mobile
>>>
>>
>>
>
>


Re: Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

Posted by Sandro Boehme <sa...@gmx.de>.
Thanks for your feedback Vlad and Dirk and for your initiative creating 
the Sightly docu Vlad!

Sadly for some reason "properties", "resource" and 
"request.getResource()" return an empty object {}.

Does anyone know what the reason could be?

Best,

Sandro

Am 18.10.15 um 09:55 schrieb Dirk Rudolph:
> I think you can use something like this:
>
> "use strict"
>
> var resource = this.request.getResource()
>
>
> use(function() { ... });
>
>
> Cheers, Dirk
>
>
> On Sunday, 18 October 2015, Vlad Bailescu <vl...@bailescu.ro> wrote:
>
>> Hi Sandro,
>>
>> I started putting together some documentation at [2] but it's stil WIP.
>>
>> Vlad
>>
>> [2] -
>> https://github.com/vladbailescu/sling-sightly-docs/blob/master/use-api.md
>>
>>
>> On Sunday, October 18, 2015, Sandro Boehme <sandro.boehme@gmx.de
>> <javascript:;>> wrote:
>>
>>> Hello,
>>>
>>> I would like to access the current resource in the Sightly JavaScript
>>> Use-API. The docu [1] says I should for example use
>>> "granite.resource.properties["title"];" to access the "title" property of
>>> the current resource. But of course "granite" is not available in Sling.
>>> This is why I'm wondering what variable is available in Sling instead.
>>>
>>> Thanks in advance for any hints,
>>>
>>> Sandro
>>>
>>> [1] -
>>>
>> http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html
>>>
>>> PS: There is no Sling docu for Sightly yet, right?
>>>
>>
>>
>> --
>> Sent from mobile
>>
>
>


Re: Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

Posted by Dirk Rudolph <di...@netcentric.biz>.
I think you can use something like this:

"use strict"

var resource = this.request.getResource()


use(function() { ... });


Cheers, Dirk


On Sunday, 18 October 2015, Vlad Bailescu <vl...@bailescu.ro> wrote:

> Hi Sandro,
>
> I started putting together some documentation at [2] but it's stil WIP.
>
> Vlad
>
> [2] -
> https://github.com/vladbailescu/sling-sightly-docs/blob/master/use-api.md
>
>
> On Sunday, October 18, 2015, Sandro Boehme <sandro.boehme@gmx.de
> <javascript:;>> wrote:
>
> > Hello,
> >
> > I would like to access the current resource in the Sightly JavaScript
> > Use-API. The docu [1] says I should for example use
> > "granite.resource.properties["title"];" to access the "title" property of
> > the current resource. But of course "granite" is not available in Sling.
> > This is why I'm wondering what variable is available in Sling instead.
> >
> > Thanks in advance for any hints,
> >
> > Sandro
> >
> > [1] -
> >
> http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html
> >
> > PS: There is no Sling docu for Sightly yet, right?
> >
>
>
> --
> Sent from mobile
>


-- 

Dirk Rudolph | Senior Software Engineer

Netcentric AG

M: +41 79 642 37 11
D: +49 174 966 84 34

dirk.rudolph@netcentric.biz | www.netcentric.biz

Re: Sightly :: JavaScript Use-API :: what property to use instead of "granite.resource" to access the current resource in JS?

Posted by Vlad Bailescu <vl...@bailescu.ro>.
Hi Sandro,

I started putting together some documentation at [2] but it's stil WIP.

Vlad

[2] -
https://github.com/vladbailescu/sling-sightly-docs/blob/master/use-api.md


On Sunday, October 18, 2015, Sandro Boehme <sa...@gmx.de> wrote:

> Hello,
>
> I would like to access the current resource in the Sightly JavaScript
> Use-API. The docu [1] says I should for example use
> "granite.resource.properties["title"];" to access the "title" property of
> the current resource. But of course "granite" is not available in Sling.
> This is why I'm wondering what variable is available in Sling instead.
>
> Thanks in advance for any hints,
>
> Sandro
>
> [1] -
> http://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html
>
> PS: There is no Sling docu for Sightly yet, right?
>


-- 
Sent from mobile