This project is archived and is in readonly mode.

#4316 ✓wontfix
Zach Hale

Naming a partial _when.html.erb throws a compile error

Reported by Zach Hale | April 3rd, 2010 @ 01:09 AM

It appears to to happen for any reserved word like 'def' because it tries to set a variable of the partial name. Bug!

compile error
/rails/project/app/views/shared/filters/_when.html.erb:1: syntax error, unexpected kWHEN, expecting kEND ...lt];f = local_assigns[:f];when = local_assigns[:when];propos...

Rails 2.3.5

Comments and changes to this ticket

  • Hugo Peixoto

    Hugo Peixoto September 18th, 2010 @ 08:10 PM

    When you create a partial such as _house.html.erb, it automatically passes the variable @house to a local variable named house. So, would you create a partial named _when.html.erb and you wouldn't be able to access the local variable named when. This, of course, isn't possible as 'when' is a reserved keyword.

    So to allow for the creation of "reserved keyword partials", this variable passing feature would have to be removed. I don't really see this as an option, so I'd rather add a note to the documentation stating this.

  • Zach Hale

    Zach Hale September 18th, 2010 @ 08:25 PM

    A reasonable conclusion. It just really threw me for a loop. Maybe an error if a reserved word is used and called as a partial?

  • Ryan Bigg

    Ryan Bigg September 18th, 2010 @ 11:05 PM

    • State changed from “new” to “open”
    • Importance changed from “” to “Low”

    I don't think this will be fixed. Catching the odd case where people name a partial that uses a reserved word will slow down partial rendering.

  • David Trasbo

    David Trasbo September 25th, 2010 @ 06:10 PM

    • State changed from “open” to “wontfix”

    I'm with Ryan on this. Marking this wontfix for now. If anyone can propose a solution that doesn't slow down this performance critical part of Rails (and prove it with benchmarks, etc.) I'll be happy to re-open.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Pages