-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report template syntax/compile error locations #25
base: master
Are you sure you want to change the base?
Conversation
Re-format buildTemplateFn() to break out markup conversion from template function construction. Next step: split off main regex replace, then turn it into a loop with source index tracking.
Step 2: break substitutions
Step 3: unroll main substitution into an explicit loop in which we can track where each subst. occurs. With this and the line-break index we build up front, we'll be able to determine the source line and start/end line inded for each replaced tag, and can then report that information when a compilation failure (i.e. bad template syntax) is detected.
(seperated from previous commit to keep the diff log more readable)
For each template tag substitution, the start and end markers are passed in to the regex replace function. If The tag isn't valid, that information is used to include line/range info in the reported error. The result is error messages like: Template command not found: foo, at 3:1-12
The \n was there in order to help with reporting accurate error location information for render-time errors, but I haven't worked the details out for that yet, so just removing the extra char for now...
This is really nice. The problem is I am still waiting for new official jquery-tmpl release. And this a a really lot changes which have to be detailed tested etc. You have to send a pull request to jquery-tmpl and create a ticket there. If they reject this features, then we have to think about how to add them, because it is really important for serverside. Would you like to create a ticket at jquery-tmpl and send pull request with your changes applied to original engine? |
I am not sure if it is clear for the client side to report line numbers if the template is inlined on the page. But there is no other way. |
Isn't jquery-tmpl project dead, can this be merged now? |
I am not sure what the state is, seems like they want to rewrite the code, but the template language api itself will be the same ... have to figure out more ... |
just wondering, what's the current status of this issue? |
This sequence of commits begins the process of adding decent error location reporting -- here, we add line/offset info to errors for invalid tags, giving the exact location of the bogus tag. Expanding it to report other compile-time errors should be easy -- I just need some test cases to figure out how they might happen.
Next, annotating the generated code with the same information for render-time reporting shouldn't be difficult; just a matter of generating tracking code for line/offset info in with the expanded tag code.
This may be getting too far away from the native impl, so if you think this is too intrusive, let me know and I'll move it to a branch in my local fork.