Skip to content

Commit

Permalink
some documentation changes
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
mitsuhiko committed Nov 10, 2007
1 parent 39e7476 commit 015b0c9
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Version 1.2
"nonlocal" keyword. This means that you can now override variables
defined in the outer scope from within a loop.

- ``foo + bar`` is now a simpler alternative to ``foo|string + bar|string``
- ``foo ~ bar`` is now a simpler alternative to ``foo|string + bar|string``

- `PackageLoader` can now work without pkg_resources too

Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include docs/build/*.html
include Makefile CHANGES LICENSE AUTHORS TODO ez_setup.py
include docs/build/*.html
include docs/src/*.txt
recursive-include tests *
28 changes: 26 additions & 2 deletions docs/src/designerdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ this:
If you have numerical indices you have to use the [] syntax:
{{ users[0].username }}

*new in Jinja 1.2*: You can now use django like attributes for integer
indices. Thus ``{{ foo.0 }}`` is equivalent to ``{{ foo[0] }}``.


Loops
=====

Expand Down Expand Up @@ -235,6 +239,9 @@ can use expressions. In expressions you can use any of the following operators:
``//`` divide the left operand by the right one and return a truncated
integer result: ``{{ 20 // 7 }}`` is ``2``.
*added in Jinja 1.1*
``~`` string concatenate a value with another one. ``{{ foo ~ bar }}``
is equivalent to ``{{ foo|string + bar|string }}``. *added in
Jinja 1.1*
``*`` multiply the left operand with the right one.
``{{ 2 * 2 }}`` would return ``4``.
``**`` raise the left operand to the power of the right
Expand All @@ -261,6 +268,18 @@ Note that there is no support for any bit operations or something similar.
instead of ``not foo is bar`` and ``not foo in bar``. All other expressions
require a prefix notation: ``not (foo and bar)``.


With Jinja 1.2 onwards it's possible to replace basic if/else blocks with the
inline `if` / `else` expression. The following two examples evaluate to the
same:

.. source:: jinja

{{ "something" if expr else "otherthing" }}

{% if expr %}something{% else %}otherthing{% endif %}


Boolean Values
==============

Expand Down Expand Up @@ -376,6 +395,7 @@ You can also specify more than one value:
For information regarding the visibility of macros have a look at the
`Scopes and Variable Behavior`_ section.


Extended Macro Call
===================

Expand Down Expand Up @@ -465,6 +485,7 @@ templates.
evaluated in an indepdendent environment by calling `rendertemplate`. See the
documentation for this function in the `builtins`_ documentation.


Filtering Blocks
================

Expand All @@ -489,6 +510,7 @@ Of course you can chain filters too:

returns ``"<b>some text</b>"``.


Defining Variables
==================

Expand All @@ -504,12 +526,14 @@ This should ouput ``foobar``.
For information regarding the visibility of variables have a look at the
`Scopes and Variable Behavior`_ section.


Reserved Keywords
=================

Jinja has some keywords you cannot use a variable names. This limitation
exists to make look coherent. Syntax highlighters won't mess things up and
you will don't have unexpected output.
exists to make templates look coherent. Syntax highlighters won't mess things
up and you won't have the situation that some names work depending on the
context.

The following keywords exist and cannot be used as identifiers:

Expand Down
1 change: 1 addition & 0 deletions docs/src/devrecipies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Recipies For Developers

Here some recipies for application developers.


Automagic Template Variables
============================

Expand Down
8 changes: 7 additions & 1 deletion docs/src/inheritance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ A child template might look like this:

The ``{% extends %}`` tag is the key here. It tells the template engine that
this template "extends" another template. When the template system evaluates
this template, first it locates the parent.
this template, first it locates the parent. It must be always the first tag
in a template but whitespace or a comment is allowed before. This was not
enforced with Jinja 1.0 and 1.1, it does however raise a syntax error with
1.2 or later.

The filename of the template depends on the template loader. For example the
``FileSystemLoader`` allows you to access other templates by giving the
Expand All @@ -93,6 +96,7 @@ value from the parent template is used instead.
two similarly-named ``{% block %}`` tags in a template, that template's
parent wouldn't know which one of the blocks' content to use.


How Inheritance Works Internally
================================

Expand Down Expand Up @@ -138,6 +142,7 @@ an syntax error. Here some examples:
However the condition is handled at runtime because it's in a valid block
and defines a new block subtemplates can override.


Super Blocks
============

Expand All @@ -156,6 +161,7 @@ to get the data of the parent you can give it an offset:
{{ super(2) }}
return the data of the second parent block


Block Shortcuts
===============

Expand Down
6 changes: 3 additions & 3 deletions docs/src/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Installing the development version
If you want to play around with the code
----------------------------------------

1. Install `Subversion`_
2. ``svn co http://trac.pocoo.org/repos/jinja/trunk jinja``
1. Install `mercurial`_
2. ``svn co http://dev.pocoo.org/hg/jinja-main jinja``
3. ``cd jinja``
4. ``ln -s jinja /usr/lib/python2.X/site-packages``

Expand Down Expand Up @@ -70,4 +70,4 @@ number.
.. _download page: http://jinja.pocoo.org/download.html
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
.. _Subversion: http://subversion.tigris.org/
.. _mercurial: http://www.selenic.com/mercurial/
1 change: 1 addition & 0 deletions docs/src/loaders.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ This mixin requires the `python-memcached`_ library.
.. _memcached: http://www.danga.com/memcached/
.. _python-memcached: http://www.tummy.com/Community/software/python-memcached/


How Mixin Classes Work
======================

Expand Down
1 change: 1 addition & 0 deletions docs/src/objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Global objects
This section covers the behavior of global objects in the Jinja namespace and
also the behavior of their attributes.


Functions
=========

Expand Down
3 changes: 3 additions & 0 deletions docs/src/scopes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Scopes and Variable Behavior
This section of the documentation covers the Jinja behavior regarding
variable visibility.


Scopes
======

Expand All @@ -30,6 +31,7 @@ Defined macros appear on the context as variables. Because of this, they are
affected by the scoping too. A macro defined inside of a macro is just available
in those two macros (the macro itself and the macro it's defined in).


Template Globals
================

Expand Down Expand Up @@ -106,6 +108,7 @@ You can of course also use the `|default` filter.
it impossible to use conditional expressions for inclusion in non root
templates.


Undefined Variables
===================

Expand Down
6 changes: 4 additions & 2 deletions jinja/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ class MemcachedLoaderMixin(object):
"""
Uses a memcached server to cache the templates.
Requires the memcache library from tummy__.
Requires the memcache library from `tummy`_ or the cmemcache library
from `Gijsbert de Haan`_.
With Jinja 1.2 onwards you can also provide a `client` keyword argument
that takes an already instanciated memcache client or memcache client
like object.
__ http://www.tummy.com/Community/software/python-memcached/
.. _tummy: http://www.tummy.com/Community/software/python-memcached/
.. _Gisjsbert de Haan: http://gijsbert.org/cmemcache/
"""

def __init__(self, use_memcache, memcache_time=60 * 60 * 24 * 7,
Expand Down
32 changes: 16 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ def build_extension(self, ext):


setup(
name = 'Jinja',
version = '1.2',
url = 'http://jinja.pocoo.org/',
license = 'BSD',
author = 'Armin Ronacher',
author_email = 'armin.ronacher@active-4.com',
description = 'A small but fast and easy to use stand-alone template '
'engine written in pure python.',
name='Jinja',
version='1.2',
url='http://jinja.pocoo.org/',
license='BSD',
author='Armin Ronacher',
author_email='armin.ronacher@active-4.com',
description='A small but fast and easy to use stand-alone template '
'engine written in pure python.',
long_description = getdoc(jinja),
# jinja is egg safe. But because we distribute the documentation
# in form of html and txt files it's a better idea to extract the files
zip_safe = False,
classifiers = [
zip_safe=False,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
Expand All @@ -76,18 +76,18 @@ def build_extension(self, ext):
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Text Processing :: Markup :: HTML'
],
keywords = ['python.templating.engines'],
packages = ['jinja', 'jinja.translators'],
data_files = [
keywords=['python.templating.engines'],
packages=['jinja', 'jinja.translators'],
data_files=[
('docs', list(list_files('docs/build'))),
('docs/txt', list(list_files('docs/src')))
],
entry_points='''
[python.templating.engines]
jinja = jinja.plugin:BuffetPlugin
''',
extras_require = {'plugin': ['setuptools>=0.6a2']},
features = {
extras_require={'plugin': ['setuptools>=0.6a2']},
features={
'speedups': Feature(
'optional C-speed enhancements',
standard = True,
Expand All @@ -103,5 +103,5 @@ def build_extension(self, ext):
]
)
},
cmdclass = {'build_ext': optional_build_ext}
cmdclass={'build_ext': optional_build_ext}
)

0 comments on commit 015b0c9

Please sign in to comment.