Skip to content
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

Make the exception message friendly #881

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link

the template method is small and smarty, but not friendly for debug. this patch can help developers to debug template. It's useful.

ReferenceError: 4
    2|     <%
    3|     // a comment
 >> 4|     if (data) { data += 12345; }; %>
    5|     <li><%= data %></li>
    6|   

data is not defined
    at eval (eval at <anonymous> (file://localhost/Users/jacksontian/fork/my_underscore/underscore.js:1196:20), <anonymous>:29:9)
    at Function._.template (file://localhost/Users/jacksontian/fork/my_underscore/underscore.js:1202:22)
    at Object.<anonymous> (file://localhost/Users/jacksontian/fork/my_underscore/test/utility.js:193:21)

@jdalton
Copy link
Contributor

jdalton commented Dec 3, 2012

I really dig the creativity here. This may not be appropriate for Underscore, but after the v1.0.0-rc.1 bump I'll check into doing something like this with Lo-Dash (which has a build step and can remove it for production builds).

@JacksonTian
Copy link
Author

Why not appropriate?

@jashkenas
Copy link
Owner

Not appropriate because Underscore templates are supposed to be as small and simple as possible. Setting a line number variable on every line of your evaluated template code doesn't fit that mission statement, and may hurt performance of important templates.

Instead, simply precompiling your templates before you send them to the browser is an easier way to get this behavior.

Very cool, though.

@jashkenas jashkenas closed this Dec 4, 2012
@JacksonTian
Copy link
Author

Actually, we usually use it at web front-end page, the performance isn't emergency, develop faster will be more important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants