-
Notifications
You must be signed in to change notification settings - Fork 5
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
Debuggers in template code #66
Comments
I looked into this a bit today. It appears the same issue is present with ERB templates: <%= binding.pry %> Leaves you here:
However, ERB has the quiet syntax like Adding a quiet syntax would be a good bit of work and starts to deviate from our origins in JSX, so I'd like to avoid it. But I do think getting a debugger in the template is a useful feature. I'm thinking it might be simplest to add special handling for expressions that just contain common debuggers (like What do you think? |
We already have the ability to control what template Ruby code is used while compiling each expression (https://github.com/patbenatar/rbexy/blob/master/lib/rbexy/nodes/expression_group.rb#L10), so I don't think it would be too tough to check the expression's content and use a raw template ( |
I’m more than ok treating this as a special case. Agreed having a quiet
syntax doesn’t make sense for rbexy, even if not having one tricks me from
time to time.
…On Mon, 18 Jan 2021 at 21:36 Nick Giancola ***@***.***> wrote:
We already have the ability to control what template Ruby code is used
while compiling each expression (
https://github.com/patbenatar/rbexy/blob/master/lib/rbexy/nodes/expression_group.rb#L10),
so I don't think it would be too tough to check the expression's content
and use a raw template (%s) instead of an output template.,
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#66 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAWH3UBT2OO2RL7INYIX4LS2THY5ANCNFSM4VNV72TA>
.
|
@lunks hmm.. on further investigation, this doesn't seem to work even with a quiet erb tag: <h1><% binding.pry %></h1> Gives me this binding:
Which is the same result as when I tried the special-casing of It appears that ERB will only put you in the right spot if the binding is on its own line, like so: <h1>
<% binding.pry %>
</h1> It turns out the secret is you need a newline in the compiled Ruby code after the This works, but it means that we end up with double newlines in the compiled output because Rbexy also compiles the newline that it found in the rbx source as a text output.. not a big deal except that the line no mapping from src to compiled output ends up off by one for lines following the debugger line, so if exceptions occur on those lines the error line will be off by one... I'm thinking this trade-off is worth it, because the use-case for a debugger suggests you may have already hit an exception and are trying to dig deeper into it. So the exception being off by one at this point is probably not that big of a deal. Thoughts? |
…uld expect in the call stack. Closes #66
Given I'm doing something like:
And I have
binding.pry
inside my rbx_product.rbx
partial, I get in a weird place where I can't accessproduct
:The text was updated successfully, but these errors were encountered: