ckirkendall / kioo

Enlive/Enfocus style templating for Facebook's React and Om in ClojureScript.
Eclipse Public License 1.0
404 stars 39 forks source link

Compile-time transformations check #53

Closed alesya-h closed 9 years ago

alesya-h commented 9 years ago

Ensure all selectors in transformations block are present in selected html fragment. This will help to ensure that html you've received from html guy is still compatible with your component definitions and you won't get 'lorem ipsum' not replaced in production and won't get missing functionality (placing component/data inside non-existent div).

ckirkendall commented 9 years ago

I like the idea but not sure throwing an exception is the right thing to do. There are cases when you don't want this type of behavior. It would be nice if we could print out warnings like the compiler (not easy from a macro in clojurescript). We could also have a top level flag that turns this feature on an off and defaults to off. We can then default to on in the next major release.

alesya-h commented 9 years ago

I've updated pull request, splitting it into 2 commits. First commit validates and throws errors, and the second one catches errors and just prints them as warnings. Second commit may be reverted for next major release, effectively turning warnings back into errors.

I'd honestly prefer this to be an error. HTML for components is always static, so it may be considered as code for page generation. If selectors cannot be found in static HTML, they have no way to magically appear. If one would wish to keep transformations that may not be applied to page, they can just comment it out, just like one would comment-out calls to non-existent functions.

alesya-h commented 9 years ago

Can you merge it, or are there anything you'd like me to change?