public
Description: PURE Unobtrusive Rendering Engine for HTML
Home | Edit | New

Tips

A better view when the compilation fails

Sometimes, the compilation HTML to JS fails and gives an alert.
For small templates that alert can be useful, for bigger ones, it is unusable (except in Opera).

You can add, to your page, a container (div, text area, …) that has the id ‘pureMsg’.
If PURE finds this container on your page, the output won’t be an alert anymore but the message will be added to this container.

You can then copy paste the JS in a smart editor like Aptana and see directly where the error comes from.

Finish by correcting either the HTML or the directives.

Run manually the compiled HTML’s

If you use firebug, you can find the compiled HTML’s at:
$p.compiledFunctions[‘<<the name of your template>>’].compiled.toString()

i.e: if you compile an HTML like $(‘div.template’).compile(‘myTemplate’, directive, context); you can find it at:
$p.compiledFunctions[‘myTemplate’].compiled.toString() or
$p.compiledFunctions.myTemplate.compiled.toString()

This can be useful if you want to test it with other contexts using the console. Or for debugging.

If you use render and autoRender without compiling first, there is a compilation on the fly.
In that case the function is given a number and can be found at:
i.e: $p.compiledFunctions[ 3 ].compiled.toString()

All the directive functions that are associated with this HTML are at:
$p.compiledFunctions[‘<<the name of your template>>’].$f0.toString()
$p.compiledFunctions[‘<<the name of your template>>’].$f1.toString(), etc…

Disable the cache of Firefox 3 when developing

I use Firebug with FF and the caching makes developing client side painful.
Here is a solution to disable the cache.

type in the address bar about:config
Type in the filter box browser.cache.check_doc_frequency
Double click the line and set the value to 1

Last edited by pure, Thu Oct 30 02:48:12 -0700 2008
Home | Edit | New
Versions: