Just to play devil's advocate, this is technically valid ```eex <% if @condition do %> <% some_side_effect() %> <% end %> ```
though that's very contrived and I can't think of a valid use-case where you wouldn't instead want ```eex <% if @condition do some_side_effect() end %> ``` +1 for adding a warning On Friday, December 4, 2020 at 10:30:31 AM UTC-8 [email protected] wrote: > Watching for a block won't catch all cases, but I can't think of any cases > where a block is used and the intent would not be to use its content. > My guess is that this could catch quite a few problems. > > Jim > > > Dr. Jim Freeze, Ph.D. > ElixirConf® > ElixirConf.com > ElixirConf.eu > (m) 512 949 9683 <(512)%20949-9683> > > > On Fri, Dec 4, 2020 at 11:53 AM Austin Ziegler <[email protected]> wrote: > >> That makes sense. Maybe the compiler can detect cases like this: >> >> ```eex >> <% variable = 'boo' %> <!-- OK --> >> <% if @bar do %> <!-- Warning or error, because of the block? --> >> ``` >> >> -a >> >> On Fri, Dec 4, 2020 at 12:50 PM Jim Freeze <[email protected]> wrote: >> >>> Yes, those bugs are annoying, but I commonly start *.html.leex docs with >>> >>> <% somevar = "blah" %> >>> ... >>> <div class="<%= somevar %>"> ... >>> >>> Jim >>> >>> On Fri, Dec 4, 2020 at 11:46 AM Austin Ziegler <[email protected]> >>> wrote: >>> >>>> I’ve had a bug in my code for the last couple of months caused by the >>>> fact that EEx isn’t ERB. Specifically, I had code that looked like: >>>> >>>> ```eex >>>> <% if @password %> >>>> Temporary Password: <%= @password %> >>>> <% else %> >>>> Sign in with your existing password. >>>> <% end %> >>>> ``` >>>> >>>> Looking at it in isolation, it’s really obvious that the first line >>>> should have been `<%= if @password %>`, but in situ…I’ve gotten multiple >>>> bug reports on this but have never been able to see what the problem was >>>> until today. >>>> >>>> Is it possible to modify the EEx compile phase so that code like I >>>> wrote above generates at least a warning? As I understand it, there’s no >>>> case where a starting EEx block will usefully begin with `<%` instead of >>>> `<%=`. >>>> >>>> -a >>>> -- >>>> Austin Ziegler • [email protected] • [email protected] >>>> http://www.halostatue.ca/ • http://twitter.com/halostatue >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "elixir-lang-core" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQs2G4HUX_y8q-UqYyTY4z5nX6JMOKdMb%3DcZSZwgpDxk0Q%40mail.gmail.com >>>> >>>> <https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQs2G4HUX_y8q-UqYyTY4z5nX6JMOKdMb%3DcZSZwgpDxk0Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/CAP1mN_z8BbAniw9k5Ee_axR-JZGvzC02Z2CoqKDs3CyMZPAA-Q%40mail.gmail.com >>> >>> <https://groups.google.com/d/msgid/elixir-lang-core/CAP1mN_z8BbAniw9k5Ee_axR-JZGvzC02Z2CoqKDs3CyMZPAA-Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Austin Ziegler • [email protected] • [email protected] >> http://www.halostatue.ca/ • http://twitter.com/halostatue >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQt_A23zpN0wROQZTKGPd4xzXCBL-LtqjGUv%3D3%2Bo40190Q%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQt_A23zpN0wROQZTKGPd4xzXCBL-LtqjGUv%3D3%2Bo40190Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/d1ae47b5-1e9f-40c3-87e9-691a9841cecdn%40googlegroups.com.
