Hi all.

If anyone is interested, I've released a new template parser for use with WO 
(can be used with Wonder, but Wonder not required):

https://github.com/undur/Parsley/

The parser is based on the code of WOOgnl from Project Wonder and thus supports 
templates that use WOOgnl style <wo:element /> inline bindings and regular 
.html/.wod templates.
There are some deviations from WOOgnl listed on the project's page, most 
notably, we do not support OGNL in bindings, although I guess support could be 
added through an extension mechanism if it turns out there's a need for it.

So, apart from being cleaned up/refactored quite a bit from the original WOOgnl 
(with a lot more work underway), it has a quality of life addition which is 
that it will render some dynamic element-related errors inline on the page, 
rather than failing the entire page display and showing a (potentially hard to 
understand) exception page.
Currently, inline errors are shown for:

- Element not found
- Bad binding configuration (in general, handles well designed elements that 
throw a WODynamicElementCreationException)
- Bad keyPaths in bindings (handling of UnknownKeyException), including 
suggesting the correct key if a misspelled one is not found

A short demonstration of this functionality can be seen here:

https://www.youtube.com/watch?v=OwL2PRel0mU

Inline error display has to be explicitly enabled and I only keep it on where 
it actually matters, in development mode, using 
Parsley.showInlineRenderingErrors( ERXApplication.isDevelopmentMode() ).
I recommend this since inline error reporting will add quite a lot of stuff to 
the parsed template and may thus be more error-prone or reduce perfomance in 
production.

I've been using the Parsley parser in production for a few weeks so I consider 
it stable, and I've now applied it to all my active projects. Keep in mind 
though that only I have used it (meaning it hasn't seen a very varied code 
style) and this is a 1.0 release with all that follows that. But if problems 
come up, I'll try to address them and release fixes as quickly as possible.

As for _why_ I'm doing this. The reasons are several, but most importantly:

1. I really wanted those inline error messages
2. As some of you may know, I've been working on my own WO-style web framework 
for a while. The actual parser in Parsley is really the parser from that 
framework (which is a ripoff of WOOgnl). Using the same template parser in both 
frameworks ensures that if/when a transition is performed, my templates are 
good to go.
3. This is the first step towards more fixes needed in WO templates. One of 
those has to do with KVC. KVC has problems accessing methods on some private 
classes, even if they implement public interfaces. This prevents you from, for 
example, accessing methods on a List constructed using 
List.of("Some","Strings") in a binding. I've already implemented a fix for this 
in my own framework, but to implement that on the WO side will take some work. 
That I'd like to do.
4. I want to enhance the parser to keep further track of what it parses, i.e. 
the exact locations of tokens in template source, so we can allow Parsley to 
suggest changes and actually perform them on the template source for you (like 
clicking a suggested correction to actually perform it).
And moreā€¦

Anyway, that's all. Hope someone finds this useful.

Cheers,
- hugi
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to