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

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Mar 24, 2015

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

This comment has been minimized.

sqlalchemy-bot commented Mar 24, 2015

Changes by Cody Taylor (@CodeMan99):

  • edited description
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 24, 2015

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

This comment has been minimized.

sqlalchemy-bot commented Mar 25, 2015

Michael Bayer (@zzzeek) wrote:

  • reword the docs a bit
  • PR is done, fixes #236

6e78429

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 25, 2015

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