sqlalchemy / sqlalchemy/mako

Improve filtering/buffering documentation.

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation feature
Dominant language
Python
Stars
459
Forks
90
PR merge metrics
No merged PRs in 30d

Description

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

The default_filters argument to a TemplateLookup could use some deeper explaining.

When I added a default HTML filter at work today there was some confusion as to why the template rendered as normal. It required about a hour of thinking and code examples before the light bulb went off. Perhaps we both were being dense, but here are my suggestions.

  1. Mention in syntax that writing is separate from filtering (unless captured).
  2. Explain default_filters before <%page expression_filters="n" />.
  3. Explain that <%page expression_filters="h" /> will append to any existing default_filters list.
  4. (Maybe) state in API documention that default_filters does not apply to <%block> <%def> and <%page>'s unbuffered writes.
  5. Provide an example of a <%def> that does not buffer in the buffering section. In particular state that the buffered example does return buf.getvalue() instead of return ''.

Relates to #111.

As always willing to implement upon agreement.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with syntax.html#expression-escaping, filtering.html sections on default_filters and buffering, and usage.html#mako.template.Template.params.default_filters. Compare the requested explanations and examples across those sections, including expression_filters ordering, unbuffered writes, and the buffered return value; done means each of the five documentation suggestions is addressed consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.