# HG changeset patch # User cmlenz # Date 1158067826 0 # Node ID 7a426ab6407a4a35cfbf4e84d1da156374c8a29d # Parent f096ad1d46e9aa771b102305bd2ada2586b80bdf * Added implementation of a simple text-based template engine. Closes #47. * Added upgrade instructions. diff --git a/UPGRADE.txt b/UPGRADE.txt new file mode 100644 --- /dev/null +++ b/UPGRADE.txt @@ -0,0 +1,29 @@ +Upgrading Genshi +================ + +Upgrading from Markup +--------------------- + +Prior to version 0.3, the name of the Genshi project was "Markup". The +name change means that you will have to adjust your import statements +and the namespace URI of XML templates, among other things: + + * The package name was changed from "markup" to "genshi". Please + adjust any import statements referring to the old package name. + * The namespace URI for directives in Genshi XML templates has changed + from http://markup.edgewall.org/ to http://genshi.edgewall.org/. + Please update the xmlns:py declaration in your template files + accordingly. + +Furthermore, due to the inclusion of a text-based template language, +the class: + + `markup.template.Template` + +has been renamed to: + + `markup.template.MarkupTemplate` + +If you've been using the Template class directly, you'll need to +update your code (a simple find/replace should do--the API itself +did not change). diff --git a/examples/bench/bigtable.py b/examples/bench/bigtable.py --- a/examples/bench/bigtable.py +++ b/examples/bench/bigtable.py @@ -12,7 +12,7 @@ import cElementTree as cet from elementtree import ElementTree as et from genshi.builder import tag -from genshi.template import Template +from genshi.template import MarkupTemplate import neo_cgi import neo_cs import neo_util @@ -38,7 +38,7 @@ table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)] -genshi_tmpl = Template(""" +genshi_tmpl = MarkupTemplate("""
@@ -46,7 +46,7 @@
""") -genshi_tmpl2 = Template(""" +genshi_tmpl2 = MarkupTemplate(""" $table
""") diff --git a/examples/transform/run.py b/examples/transform/run.py --- a/examples/transform/run.py +++ b/examples/transform/run.py @@ -5,11 +5,11 @@ import sys from genshi.input import HTMLParser -from genshi.template import Context, Template +from genshi.template import Context, MarkupTemplate def transform(html_filename, tmpl_filename): tmpl_fileobj = open(tmpl_filename) - tmpl = Template(tmpl_fileobj, tmpl_filename) + tmpl = MarkupTemplate(tmpl_fileobj, tmpl_filename) tmpl_fileobj.close() html_fileobj = open(html_filename) diff --git a/genshi/plugin.py b/genshi/plugin.py --- a/genshi/plugin.py +++ b/genshi/plugin.py @@ -21,7 +21,7 @@ from genshi.core import Attrs, Stream, QName from genshi.eval import Undefined from genshi.input import HTML, XML -from genshi.template import Context, Template, TemplateLoader +from genshi.template import Context, MarkupTemplate, Template, TemplateLoader def ET(element): """Converts the given ElementTree element to a markup stream.""" @@ -59,7 +59,7 @@ a string. """ if template_string is not None: - return Template(template_string) + return MarkupTemplate(template_string) divider = templatename.rfind('.') if divider >= 0: diff --git a/genshi/template.py b/genshi/template.py --- a/genshi/template.py +++ b/genshi/template.py @@ -31,7 +31,8 @@ from genshi.path import Path __all__ = ['BadDirectiveError', 'TemplateError', 'TemplateSyntaxError', - 'TemplateNotFound', 'Template', 'TemplateLoader'] + 'TemplateNotFound', 'MarkupTemplate', 'TextTemplate', + 'TemplateLoader'] class TemplateError(Exception): @@ -216,7 +217,7 @@ of `(name, value)` tuples. The items in that dictionary or sequence are added as attributes to the element: - >>> tmpl = Template('''