Update internal documentation.
This commit is contained in:
parent
b923f34888
commit
c849c01363
1 changed files with 20 additions and 8 deletions
28
__init__.py
28
__init__.py
|
|
@ -26,8 +26,11 @@
|
||||||
Secretary
|
Secretary
|
||||||
Take the power of Jinja2 templates to OpenOffice and LibreOffice.
|
Take the power of Jinja2 templates to OpenOffice and LibreOffice.
|
||||||
|
|
||||||
This file implements BaseRender. BaseRender prepares a XML which describes
|
This file implements Render. Render provides an interface to render
|
||||||
ODT document content to be processed by jinja2 or Django template system.
|
Open Document Format (ODF) documents to be used as templates using
|
||||||
|
the jinja2 template engine. To render a template:
|
||||||
|
engine = Render(template_file)
|
||||||
|
result = engine.render(template_var1=...)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
@ -76,11 +79,18 @@ def pad_string(value, length=5):
|
||||||
|
|
||||||
class Render():
|
class Render():
|
||||||
"""
|
"""
|
||||||
Prapares a XML string or file to be processed by a templating system.
|
Main engine to convert and ODT document into a jinja
|
||||||
|
compatible template. Render provides an enviroment
|
||||||
|
variable which can be manipulated to provide custom
|
||||||
|
filters to the ODF render.
|
||||||
|
|
||||||
|
engine = Render('template.odt')
|
||||||
|
engine.enviroment.filters['custom_filer'] = filter_function
|
||||||
|
result = engine.render()
|
||||||
|
|
||||||
Use example:
|
Basic use example:
|
||||||
render = BaseRender('content/xml', var1, var2.. varN)
|
engine = Render('template')
|
||||||
render.render
|
result = engine.render()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_template = None
|
_template = None
|
||||||
|
|
@ -109,8 +119,10 @@ class Render():
|
||||||
# def __init__(self, xml_doc, template_args):
|
# def __init__(self, xml_doc, template_args):
|
||||||
def __init__(self, template, **kwargs):
|
def __init__(self, template, **kwargs):
|
||||||
"""
|
"""
|
||||||
Builds a ODFRender instance
|
Builds a Render instance and assign init the internal enviroment.
|
||||||
TODO: document
|
Params:
|
||||||
|
template: Either the path to the file, or a file-like object.
|
||||||
|
If it is a path, the file will be open with mode read 'r'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.template = template
|
self.template = template
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue