# DocumentTree in Javascript extension, Angular JS

**URL:** <https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253>\
**Category:** Help / Discuss\
**Tags:** script\
**Created:** [June 29, 2017, 8:37am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253 "2017-06-29T08:37:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaBoi](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@DaBoi](https://forum.xwiki.org/u/DaBoi)\
**Post date:** [June 29, 2017, 8:37am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/1 "2017-06-29T08:37:32Z")

</div>

I want to create a custom navigation menu using Angular JS and a skin extension. My current problem is that **my mixed in Velocity doesn’t seem to be parsed**. Here’s a snippet that i put into a JavaScriptExtension object:

```
var tree = #documentTree({
'showTranslations' : 'false',
"root" : "document:Products.WebHome",
"filterHiddenDocuments" : "true",
"showAttachments" : "false",
"compact" : "true" : 
"limit" : "25",
"openTo" : "document:$openToDoc"
});

console.log(tree);

```

This results in an uncaught exception since the resulting JS that is executed is exactly what is above; it’s not parsed. I’ve tried other Velocity snippets and they work.

I’ve also tried:

```
{{template name="documentTree_macros.vm" /}}

{{velocity}}
{{html}}
#documentTree({})
{{/html}}
{{/velocity}}

```

Which also isn’t parsed and the resulting JS is exactly as above.

Perhaps using a DocumentTree is not the optimal way for building a custom navigation menu? Maybe there is a way to loop through all of the documents in the wiki and use JS to create HTML elements for them. Or am I using Velocity wrong?

Thank you 🙂!

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [June 29, 2017, 8:45am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/2 "2017-06-29T08:45:41Z")

</div>

Are you sure you’ve selected the xproperty inside the JavaScriptExtension xobject to parse Velocity?

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [June 29, 2017, 8:46am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/3 "2017-06-29T08:46:44Z")

</div>

ah wait you cannot do what you did 🙂

A velocity macro has to start the line and cannot return a result, so the following cannot work:

```auto
var tree = #documentTree...

```

---

<div class="post-metadata">

**Author:** ![DaBoi](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@DaBoi](https://forum.xwiki.org/u/DaBoi)\
**Post date:** [June 29, 2017, 8:47am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/4 "2017-06-29T08:47:38Z")

</div>

Yes, I have chosen “Yes” on “Parse content”.  
Allright, any suggestions as to how I could do it instead?

---

<div class="post-metadata">

**Author:** ![DaBoi](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@DaBoi](https://forum.xwiki.org/u/DaBoi)\
**Post date:** [June 29, 2017, 9:09am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/5 "2017-06-29T09:09:57Z")

</div>

Perhaps the xwiki documentlist could be used? I can’t seem to be able to get it to be parsed though;

```
var docStuff = '$xwiki.wikimanager.getWikiDocumentList()';
console.log(docStuff);

```

prints “$xwiki.wikimanager.getWikiDocumentList()” to the console (and leaving out the quotes on the first line gives “Uncaught ReferenceError: $xwiki is not defined”.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [June 29, 2017, 9:12am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/6 "2017-06-29T09:12:52Z")

</div>

If you use single quotes then you’re telling Velocity to not parse the content… see [Apache Velocity Engine - User Guide](http://velocity.apache.org/engine/2.0/user-guide.html)

---

<div class="post-metadata">

**Author:** ![DaBoi](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@DaBoi](https://forum.xwiki.org/u/DaBoi)\
**Post date:** [June 29, 2017, 9:26am UTC](https://forum.xwiki.org/t/documenttree-in-javascript-extension-angular-js/253/7 "2017-06-29T09:26:02Z")

</div>

Gotcha, I’m very new to Velocity. Doesn’t answer my question though. The problem is how to with JS (through perhaps Velocity) access information about which pages exist in the wiki.
