Grails
  1. Grails
  2. GRAILS-2116

Path for unqualified templates (in a render tag) should default to that of the including view, not the calling controller.

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.0-RC3
    • Fix Version/s: 3.0
    • Component/s: View technologies
    • Labels:
      None

      Description

      It appears that the path for unqualified template names corresponds to the calling controller, not the including view. That is, if a tag like:

      <g:render template="footer" />

      is included in the view shared/index.gsp which is being rendered by, say, the UserController with a call like:

      render(view:'/shared/index')

      Then grails looks for _footer.gsp in views/user, not views/shared. It seems strange for the behavior of the render tag and the view to depend on which controller is using it. It makes it harder to create a modular set of views, as they need to include hardcoded paths to their own location; e.g., shared/index.gsp would contain:

      <g:render template="/shared/footer" />

      This makes it more difficult to move the views (e.g. from "shared" to "admin"), as these hard-coded paths need to be changed.

        Activity

        Hide
        David A. Mellis added a comment -

        A simple grails application demonstrating the problem.

        Show
        David A. Mellis added a comment - A simple grails application demonstrating the problem.
        Hide
        Peter Ledbrook added a comment -

        I think this would be a fairly significant breaking change, so it's best to aim for 2.0 with this.

        Show
        Peter Ledbrook added a comment - I think this would be a fairly significant breaking change, so it's best to aim for 2.0 with this.

          People

          • Assignee:
            Unassigned
            Reporter:
            David A. Mellis
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development