Skip to content

emit warning when a block or def is named "body" #263

Open

Description

@sqlalchemy-bot

Migrated issue, originally created by Bérenger Enselme (@benselme)

This is using CPython 3.6.1

from mako.template import Template

if __name__ == '__main__':
    s = Template("""aaaa<%block name="bodi"></%block>bbbb""").render()
    assert s == 'aaaabbbb'  # success
    s = Template("""aaaa<%block name="body"></%block>bbbb""").render()
    assert s == 'aaaabbbb'  # failure, s == '\n '

Activity

  1. sqlalchemy-bot commented on May 19, 2017

    @sqlalchemy-bot
    Author

    Changes by Bérenger Enselme (@benselme):

    • edited description
  2. sqlalchemy-bot commented on May 19, 2017

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    this is expected behavior. "body" is a pre-existing name with special behavior and is documented here. It is possible people use it as a "block" name intentionally.

  3. sqlalchemy-bot commented on May 19, 2017

    @sqlalchemy-bot
    Author

    Changes by Michael Bayer (@zzzeek):

    • changed title from "Blank output when there is a block named "body"" to "emit warning when a block or def is named "body""
  4. sqlalchemy-bot commented on May 19, 2017

    @sqlalchemy-bot
    Author

    Bérenger Enselme (@benselme) wrote:

    Thanks, I get it now. I was aware of the body() function but it was not obvious at all that naming a block "body" would overwrite it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions