Skip to content

Commit

Permalink
add developer note about jinja whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin J. Mitchell committed Mar 7, 2010
1 parent f29c62c commit a3942c1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/developer.texinfo
Expand Up @@ -17,6 +17,7 @@ described here.
* The Event Loop::
* String Types::
* Subscription Interfaces::
* Jinja Web Templates::
* Twisted Idioms::
* Testing Idioms and Utilities::
* Developer Class Index::
Expand Down Expand Up @@ -232,6 +233,50 @@ TODO

TODO use @code{buildbot.eventually}

@node Jinja Web Templates
@section Jinja Web Templates

Buildbot uses Jinja2 to render its web interface. The authoritative source for
this templating engine is @uref{http://jinja.pocoo.org/2/documentation/, its
own documentation}, of course, but a few notes are in order for those who are
making only minor modifications.

@heading Whitespace

Jinja directives are enclosed in @code{@{% .. %@}}, and sometimes also have
dashes. These dashes strip whitespace in the output. For example:

@example
@{% for entry in entries %@}
<li>@{@{ entry @}@}</li>
@{% endfor %@}
@end example

will produce output with too much whitespace:

@example
<li>pigs</li>
<li>cows</li>
@end example

But adding the dashes will collapse that whitespace completely:

@example
@{% for entry in entries -%@}
<li>@{@{ entry @}@}</li>
@{%- endfor %@}
@end example

yields

@example
<li>pigs</li><li>cows</li>
@end example

@node Twisted Idioms
@section Twisted Idioms

Expand Down

0 comments on commit a3942c1

Please sign in to comment.