}}}
}}}
{{{#!td
{{{#!html+jinja
# block content
# set modify_perm = 'WIKI_MODIFY' in perm(page.resource)
# set create_perm = 'WIKI_CREATE' in perm(page.resource)
# set admin_perm = 'WIKI_ADMIN' in perm(page.resource)
# set is_not_latest = page.exists and page.version != latest_version
}}}
}}}
|-----------------------------------------------------------------------------
{{{#!td colspan=2 style="font-style: italic"
We start the ''content'' block. As before with the ''header'' block, we define some variables at the beginning of the block.
}}}
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
Version $page.version (modified by ${authorinfo(page.author)},
${pretty_dateinfo(page.time)})
(diff)
|
${wiki_to_html(context, page.comment or '--')}
|
}}}
}}}
{{{#!td
{{{#!html+jinja
# if version:
# with
# set version = page.version
# set author = authorinfo(page.author)
# set date = pretty_dateinfo(page.time)
# set hef = href.wiki(page.name, action='diff', version=page.version)
# trans version, author, date, href
Version ${version} (modified by ${author}, ${date})
(diff)
# endtrans
# endwith
|
${wiki_to_html(context, page.comment or '--')}
|
# endif
}}}
}}}
|-----------------------------------------------------------------------------
{{{#!td colspan=2 style="font-style: italic"
Here we illustrate the i18n changes.
First, any sentence that corresponds to visible end-user text that should be
translated has to be marked somehow.
One way is to use the standard i18n calls,
`_`, `ngettext()`, etc.
The other way is to use `trans` blocks.
There are two big differences with their Genshi i18n equivalent:
- variable substitutions can only be those of direct variables,
no kind of expression is allowed, even as simple as attribute
lookup
- Jinja2, markup neutral as it is, will not do any substitutions
on the markup found in a trans block; what would have ended
in a Genshi bracketed expression `... [1:diff]` in the catalogs
will now remain HTML markup: `...
diff`.
Note that one can use a `with` statement for breaking up the
assignments needed on multiple separate lines.
Smaller lists of variables can be placed on the `trans` line directly.
}}}
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
Last modified
${pretty_dateinfo(page.time)}
Last modified on
${format_datetime(page.time)}
The page ${name_of(page.resource)}
does not exist. You can create it here.
}}}
}}}
{{{#!td
{{{#!html+jinja
# if page.exists:
${
wiki_to_html(context, text)
}
# set last_modification = (page.comment and
_('Version %(version)s by %(author)s: %(comment)s',
version=page.version, author=format_author(page.author),
comment=page.comment) or
_('Version %(version)s by %(author)s',
version=page.version, author=format_author(page.author)))
# if not version:
# with
# set href = href.wiki(page.name, action='diff',
version=page.version),
# set date = pretty_dateinfo(page.time)
# trans href, last_modification, date
Last modified ${date}
# endtrans
# endwith
${_("Last modified on %(date)s", date=format_datetime(page.time))}
# endif
# else:
# trans name = name_of(page.resource)
The page ${name} does not exist.
You can create it here.
# endtrans
# endif
}}}
}}}
|-----------------------------------------------------------------------------
|||| ||
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
}}}
}}}
{{{#!td
{{{#!html+jinja
# with
# set alist = attachments
# set compact = True
# set foldable = True
# include "list_of_attachments.html"
# endwith
}}}
}}}
|-----------------------------------------------------------------------------
{{{#!td colspan=2 style="font-style: italic"
Jinja2 includes also know about their context, so that make them kind of parametric.
}}}
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
# endif
# endwith
}}}
}}}
|-----------------------------------------------------------------------------
|||| ||
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
You could also create the same page higher in the hierarchy:
}}}
}}}
{{{#!td
{{{#!html+jinja
# if not page.exists and higher:
You could also create the same page higher in the hierarchy:
# for markup in higher:
- ${markup}
# endfor
# endif
}}}
}}}
|-----------------------------------------------------------------------------
{{{#!td colspan=2 style="font-style: italic"
Here's the first use of the `for` statement. Straightforward.
}}}
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi
The following pages have a name similar to this page,
and may be related:
}}}
}}}
{{{#!td
{{{#!html+jinja
# if not page.exists and related:
${_("The following pages have a name similar to this page, and may be related:")}
# for markup in related:
- ${markup}
# endif
# endif
}}}
}}}
|-----------------------------------------------------------------------------
|||| ||
|-----------------------------------------------------------------------------
{{{#!td
{{{#!html+genshi