We provide a set of very sophisticated XHTML template files for generating Web content for shop software or other e-commerce applications.
All templates and code are available free of charge under the LGPL license.
The templates and documentation are available from http://code.google.com/p/templates4goodrelations/downloads/list
The templates can be used to generate either a complete XHTML page or a snippet of additional
elements that can be inserted into any HTML page just before the closing
element.
The type of result is controlled via the "snippet" parameter.
If you have full control over the page template, it will be easier to use snippet=False and insert all of your visible XHTML markup into the respective template file.
If it is likely that users of your application edit or replace your XHTML templates, it is better to create RDFa snippets only and insert them just before the final HTML is sent to the client.
...
snippet = template.render(company_data, snippet=True) # populate template snippet = snippet.encode('UTF-8')
{=html} <body>
element.html = static_html.replace("
", snippet+"
") print html
'company_name' : "Best Purchase Electronics Shop Ltd.", # Official name of the business making the offer
'country' : "Germany",
'language' : "en", # ISO 639-1 code for the language of the country name, see
http://en.wikipedia.org/wiki/ISO_639-1
'city' : "Munich",
'zip' : "12345",
'street' : "Example Street 123",
'phone' : "+49-89-6004-4217", # Must include international prefix
'logo_uri' : "
http:/www.heppnetz.de/gr4shops/logo.jpg
"
}
from jinja2 import * loader = FileSystemLoader('.') env = Environment( loader=loader, autoescape=True, trim_blocks=True) template = env.get_template('template-company.html')
title = "Website of Best Purchase Electronics Shop Ltd." html = template.render(company_data, snippet=False, title=title) # populate template html = html.encode('UTF-8') print html
static_html = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
Demo page