Package: kajiki
Kajiki provides fast well-formed XML templatesBecause Kajiki’s input is XML, it can ensure that your HTML/XML output is
well-formed. The Genshi-like syntax, based on XML attributes or tags, is simply
beautiful and easily understood (or ignored) by web designers.
But instead of the slow performance ofGenshi, Kajiki compiles
templates to Python code that renders with blazing-fast speed, so Kajiki can
compete with the speed ofJinja,Mako,Chameleonand others.
Also, one of Genshi’s misfeatures – py:match – is replaced with blocks which
work like Jinja’s blocks.By combining the best ideas out there – XML input,
Genshi’s syntax and features, Jinja’s template inheritance and final
compilation to Python –, Kajiki is ready to become
the most widely used templating engine for web development in Python.
And more features are coming soon; stay tuned!Example>>>importkajiki>>>Template=kajiki.XMLTemplate('''<html>
...     <head><title>$title</title></head>
...     <body>
...         <h1>$title</h1>
...         <ul>
...             <li py:for="x in range(repetitions)">$title</li>
...         </ul>
...     </body>
... </html>''')>>>print(Template(dict(title='Kajiki is teh awesome!',repetitions=3)).render())<html><head><title>Kajikiistehawesome!</title></head><body><h1>Kajikiistehawesome!</h1><ul><li>Kajikiistehawesome!</li><li>Kajikiistehawesome!</li><li>Kajikiistehawesome!</li></ul></body></html>LinksDocumentationKajiki is licensed under an MIT-stylelicense.The git repository andissue trackerare atGitHub. Previously the project
usedSourceForgefor the hg repository, issue tracker and forums.CHANGES0.9.2 (2022-11-24)Python 3.11 compatibility.Documentation updates and clarifications.Unit test updates.0.9.1 (2022-04-20)Fixed compatibility for Python 3.11 alpha.The unit tests were moved out of thekajikipackage: tests are
now under thetests/directory.Migrated from Travis CI to GitHub Actions.0.9.0 (2021-11-29)Support dropped for Python 2.7.Fixed up lnotab bugs in Python 3.6+ (ERROR LOOKING UP LINEmessages).DTD will not be inserted before an<?xml...?>declaration
anymore.Dependency onninedropped.Dropped integration for TurboGears 1.Improved end-to-end testing.NoteKajiki 0.9.x will be the last series to support Python 3.4 and 3.5.
Users are encouraged to upgrade to Python 3.6+ soon.0.8.3 (2021-06-18)Fixed compatibility for Python 3.10Switched the test runner to pytestAdded thekajikicommand line interfaceDocumentation typo correctionsNoteKajiki 0.8.3 will be the last release to support Python 2.7.
Kajiki 0.9 will require Python 3.4+.0.8.2 (2019-11-26)Fixed some HTML entities not being properly recognised0.8.1 (2019-10-20)Fixed unexpected <DOCTYPE> when including templates0.8.0 (2019-06-03)Fixed support for Python 3.8Dropped support for Python 2.6 and 3.30.7.2 (2018-04-16)Improve parsing of${}expressions and fix syntax errors reporting in braced expressions.Improve parsing of documents with comments before the root element0.7.1 (2017-09-11)Allow to replacegettextfunction by providing it in the template context or throughbase_globalsin Loader0.7.0 (2017-06-27)Text for i18n is now extracted ignoring the empty spaces surrounding the text itself. Empty text will always be treated as non translatable nodes for performance reasons.extract_pythonoption will now report syntax errors when extracting text for translation.0.6.3 (2017-05-25)Addedextract_pythonoption to babel message extractor, this allows extracting gettext calls in${}expressions0.6.1 (2016-11-28)Actually report 0.6 in kajiki/version.pyExposestrip_textoption in loader0.6.0 (2016-11-27)Fixedpy:switcherror message wrongly mentioningpy:withSupport for multiline${}expressionsSubsequent text nodes are now squashed into a single text node. This allows translating whole paragraphs instead of single sentences.Allow code and function calls inside tag attributesAddedstrip_textoption to XMLTemplate and i18n collector to ensure leading and trailing spaces are stipped by text nodes (also leads to minified HTML)Some HTML nodes that do not require being closed but is commonly considered best practice to close them are now emitted with ending tag (IE: <p>)Generally improved code documentation to lower entry barrier for contributors0.5.5 (2016-06-08)py:attrswill now emit the attribute name itself or will omit the attribute at all in case ofboolvalues for ‘checked’, ‘disabled’, ‘readonly’, ‘multiple’, ‘selected’, ‘nohref’,
‘ismap’, ‘declare’ and ‘defer’,0.5.4 (2016-06-04)py:switchnow correctly supports multiplepy:casestatements.text inside<script>and<style>tags is no longer collected translation.Syntax errors now report the line and the surrounding code when there is a markup or python syntax error.Aspy:swtichdiscards all its content apart frompy:caseandpy:elsestatements it will now correctly report an error when the statements has other content.py:elsewill now correctly detect spurious content between itself andpy:ifas the two must be consequential.Improved code documentation on core classes.0.5.3 (2016-01-25)py:withstatement now keeps order of variables, so that variables can depend from each other.Babel is no longer a dependency unless you want to use the message extractor.0.5.2 (2015-10-13)TranslatableTextNodes are now only generated for non-empty stringspy:withstatement now accepts multiple variables separated by semicolonBabel message extractor fixed on Python20.5.1 (2015-07-26)Fix crash on PyPy0.5.0 (2015-07-25)CDATA sections created by the user are now properly preservedcdata_scripts=Falseoption inXMLTemplateallows disabling automatic CDATA for script and style tags.Autoblocks experimental feature automatically creates blocks from specified tag names.0.4.4 (2013-09-07)Also accept “$.” without erroring out. In fact, accept anything.Add integration plugin for TurboGears 10.4.3 (2013-08-12)Accept “$(” without erroring out. Easier to write jQuery stuff.0.4.2 (2013-08-01)There was a showstopper regression in FileLoader. Fixes #10.4.0 (2013-07-29)Support Python versions 2.6, 2.7, 3.2, 3.3 in a single codebase
using theninelibrary.Support HTML entities as well as XML entities in input templates.py:include fixed, can see global variables.Genshi compatibility: support built-in functions:
defined(), value_of() and Markup().py:def: Do not crash if a function has no content.py:strip=''is the same aspy:strip='True'.Correctness: escape HTML attribute values.Correctness: Always close script tags, even in XML mode.Add integration module for the Pyramid web framework.Give the FileLoader apath, not just a basedirectory.Documentation improvements, including the need to write CDATA sections.Move from Sourceforge to Github.Use Travis for continuous integration.The whole codebase is formatted according to PEP8.0.3.5 (2012-05-07)Several bugfixesOutput HTML attributes in alphabetical order (for testability)0.3.4 (2011-06-01)Make Kajiki work on Python 2.40.3.2 (2010-11-26)Fix Python 2.5 syntax error0.3.1 (2010-11-24)Add support for py:withRemove unused babel import that was breaking pip/easy_installPython 2.5 fixesCorrectly strip None attributes and expressionsTurn off autoescaping in text templates0.3 (2010-10-10)Adds i18n supportFixes several bugs: [#7], [#9], [#10]