Documentation

25 views
Skip to first unread message

Chris Jeffries

unread,
Jul 3, 2018, 2:13:12 PM7/3/18
to JavaScript Templates Engine PURE
Is there a reference document for PURE. Examples are great, but a reference is useful as a memory jogger. Also an error listing.  I listed these from the pure.js code, but I did not seek into any other libraries so I do not know if it is complete. Also the comments below each error are my guess as to what they might mean. For some I just do not know.

Is anyone willing to help me make this complete, accurate and helpful?

PURE Errors

If a PURE method encounters a situation that it cannot handle it throws an error describing the problem. The following is a list of the errors PURE can throw. You can catch these errors by putting your method calls in a try{…} catch(e){…} block.

The template <selector> was not found

No element in your web page matches the selector you supplied. Check the selector syntax above, and the class or id of the item you are trying to select.

The root of the template is undefined, check your selector

bad loop spec: <selector>:<loop specification>

"item<-..." is a reserved word for the current running iteration. Please choose another name for your loop.

bad selector syntax: <selector>

Your selector must be well formed. See the reference above for details of well formed selectors

The node <selector> was not found in the template:<template>

You have tried to name a place in your template which is not there. Possible reasons

  • You misstyped the selector

  • The selector is outside the selected template

  • The wrong template was selected

append/prepend cannot take place at the same time

You specified an action to extract a value from the data and both prepend and append it to the current content of the selected element. i.e. you had a link specifier like this

“<selector>”:”+<dataname>+”

That is not allowed. Try “selector”:”+dataname”, “selector”:”dataname+” if you really want to do this.

no append/prepend/replace modifiers allowed for loop target

Not sure what this means

cannot append with loop (sel: <selector>)

Not sure what this means

The template root, can't be looped.

You specified a loop item as your entire template. e.g. <li class=iterated></li> and then selected ‘iterated’ as your template. Try

<ol id=myloop>

<li class=iterated></li>

</ol>

and specify ‘myloop’ as your template.

sort is only available on arrays, not objects

JSON objects are defined as ‘unordered’, i.e. the order of the items is unpredictable. So sorting is not an option. Try to organise your data into an array ( […]) if you want to sort it.

cannot have more than one loop on a target

You have tried to loop over two separate arrays on the same target. You cannot do this. Instead, create a second target for the second loop. e.g.

<li class=loop1><li>

<li class=loop2><li>

Error in the selector: <selector> A directive action must be a string, a function or a loop(←)

You specified an <action> that was not a string (accessing a value in your data by its property name), a (lambda) function, or an object containing a loop specification. Check the <action> of the <selector> specified for typos etc.

Mic (BeeBole)

unread,
Jul 8, 2018, 12:36:04 PM7/8/18
to JavaScript Templates Engine PURE
Let me check with the team how and where the documentation is stored today.
And I'll check how this can be added somewhere crediting your contribution .

Thank you for this.

Chris Jeffries

unread,
Jul 9, 2018, 1:15:27 AM7/9/18
to JavaScript Templates Engine PURE
Here is the whole file I created including CSS and HTML references so to be easily to hand. But it is not complete. I am happy to research other things - if I know they exist.
reference.odt
Reply all
Reply to author
Forward
0 new messages