Skip to content
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

Exiting/Returning Early from a Template #236

Closed
sqlalchemy-bot opened this issue Mar 24, 2015 · 4 comments
Closed

Exiting/Returning Early from a Template #236

sqlalchemy-bot opened this issue Mar 24, 2015 · 4 comments

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Cody Taylor (@CodeMan99)

The documentation for Returning early from a template should suggest return an empty string. Otherwise python returns None and that may appear in your rendered template.

We should also consider adding a constant to represent exiting a template for two reasons.

  1. Seeing return in the middle of a block of text can be very confusing since its normal syntax only holds meaning within a function or method.
  2. Would ensure that the suggestion of returning an empty string allows holds true. The first time I saw None in my rendered template I was really confused.

I would be more than willing to implement this change, but I would not know where to add the suggested constant.

@sqlalchemy-bot
Copy link
Author

Changes by Cody Taylor (@CodeMan99):

  • edited description

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

add the constant to mako/runtime.py, have it be available in templates which means its part of codegen.py in the symbols at the top (e.g. like UNDEFINED), then make the appropriate changes in the doc rst's. the docs have to include a ".. versionadded:: " directive to show that this constant isn't available in older versions of Mako also ( I can help format those).

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

6e78429

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

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

No branches or pull requests

1 participant