|
@@ -1,7 +1,7 @@
|
|
|
API
|
|
|
===
|
|
|
|
|
|
-.. module:: jinja2
|
|
|
+.. module:: ambari_jinja2
|
|
|
:synopsis: public Jinja2 API
|
|
|
|
|
|
This document describes the API to Jinja2 and not the template language. It
|
|
@@ -26,7 +26,7 @@ are in use.
|
|
|
The simplest way to configure Jinja2 to load templates for your application
|
|
|
looks roughly like this::
|
|
|
|
|
|
- from jinja2 import Environment, PackageLoader
|
|
|
+ from ambari_jinja2 import Environment, PackageLoader
|
|
|
env = Environment(loader=PackageLoader('yourapplication', 'templates'))
|
|
|
|
|
|
This will create a template environment with the default settings and a
|
|
@@ -130,7 +130,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
|
|
|
|
|
|
If the environment is sandboxed this attribute is `True`. For the
|
|
|
sandbox mode have a look at the documentation for the
|
|
|
- :class:`~jinja2.sandbox.SandboxedEnvironment`.
|
|
|
+ :class:`~ambari_jinja2.sandbox.SandboxedEnvironment`.
|
|
|
|
|
|
.. attribute:: filters
|
|
|
|
|
@@ -216,7 +216,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
|
|
|
.. automethod:: stream([context])
|
|
|
|
|
|
|
|
|
-.. autoclass:: jinja2.environment.TemplateStream()
|
|
|
+.. autoclass:: ambari_jinja2.environment.TemplateStream()
|
|
|
:members: disable_buffering, enable_buffering, dump
|
|
|
|
|
|
|
|
@@ -242,7 +242,7 @@ for all other extensions::
|
|
|
|
|
|
env = Environment(autoescape=guess_autoescape,
|
|
|
loader=PackageLoader('mypackage'),
|
|
|
- extensions=['jinja2.ext.autoescape'])
|
|
|
+ extensions=['ambari_jinja2.ext.autoescape'])
|
|
|
|
|
|
When implementing a guessing autoescape function, make sure you also
|
|
|
accept `None` as valid template name. This will be passed when generating
|
|
@@ -283,7 +283,7 @@ others fail.
|
|
|
The closest to regular Python behavior is the `StrictUndefined` which
|
|
|
disallows all operations beside testing if it's an undefined object.
|
|
|
|
|
|
-.. autoclass:: jinja2.Undefined()
|
|
|
+.. autoclass:: ambari_jinja2.Undefined()
|
|
|
|
|
|
.. attribute:: _undefined_hint
|
|
|
|
|
@@ -311,9 +311,9 @@ disallows all operations beside testing if it's an undefined object.
|
|
|
:attr:`_undefined_exception` with an error message generated
|
|
|
from the undefined hints stored on the undefined object.
|
|
|
|
|
|
-.. autoclass:: jinja2.DebugUndefined()
|
|
|
+.. autoclass:: ambari_jinja2.DebugUndefined()
|
|
|
|
|
|
-.. autoclass:: jinja2.StrictUndefined()
|
|
|
+.. autoclass:: ambari_jinja2.StrictUndefined()
|
|
|
|
|
|
Undefined objects are created by calling :attr:`undefined`.
|
|
|
|
|
@@ -345,7 +345,7 @@ Undefined objects are created by calling :attr:`undefined`.
|
|
|
The Context
|
|
|
-----------
|
|
|
|
|
|
-.. autoclass:: jinja2.runtime.Context()
|
|
|
+.. autoclass:: ambari_jinja2.runtime.Context()
|
|
|
:members: resolve, get_exported, get_all
|
|
|
|
|
|
.. attribute:: parent
|
|
@@ -389,7 +389,7 @@ The Context
|
|
|
|
|
|
The current :ref:`eval-context`.
|
|
|
|
|
|
- .. automethod:: jinja2.runtime.Context.call(callable, \*args, \**kwargs)
|
|
|
+ .. automethod:: ambari_jinja2.runtime.Context.call(callable, \*args, \**kwargs)
|
|
|
|
|
|
|
|
|
.. admonition:: Implementation
|
|
@@ -416,22 +416,22 @@ size by default and templates are automatically reloaded.
|
|
|
All loaders are subclasses of :class:`BaseLoader`. If you want to create your
|
|
|
own loader, subclass :class:`BaseLoader` and override `get_source`.
|
|
|
|
|
|
-.. autoclass:: jinja2.BaseLoader
|
|
|
+.. autoclass:: ambari_jinja2.BaseLoader
|
|
|
:members: get_source, load
|
|
|
|
|
|
Here a list of the builtin loaders Jinja2 provides:
|
|
|
|
|
|
-.. autoclass:: jinja2.FileSystemLoader
|
|
|
+.. autoclass:: ambari_jinja2.FileSystemLoader
|
|
|
|
|
|
-.. autoclass:: jinja2.PackageLoader
|
|
|
+.. autoclass:: ambari_jinja2.PackageLoader
|
|
|
|
|
|
-.. autoclass:: jinja2.DictLoader
|
|
|
+.. autoclass:: ambari_jinja2.DictLoader
|
|
|
|
|
|
-.. autoclass:: jinja2.FunctionLoader
|
|
|
+.. autoclass:: ambari_jinja2.FunctionLoader
|
|
|
|
|
|
-.. autoclass:: jinja2.PrefixLoader
|
|
|
+.. autoclass:: ambari_jinja2.PrefixLoader
|
|
|
|
|
|
-.. autoclass:: jinja2.ChoiceLoader
|
|
|
+.. autoclass:: ambari_jinja2.ChoiceLoader
|
|
|
|
|
|
|
|
|
.. _bytecode-cache:
|
|
@@ -449,10 +449,10 @@ the application.
|
|
|
|
|
|
To use a bytecode cache, instanciate it and pass it to the :class:`Environment`.
|
|
|
|
|
|
-.. autoclass:: jinja2.BytecodeCache
|
|
|
+.. autoclass:: ambari_jinja2.BytecodeCache
|
|
|
:members: load_bytecode, dump_bytecode, clear
|
|
|
|
|
|
-.. autoclass:: jinja2.bccache.Bucket
|
|
|
+.. autoclass:: ambari_jinja2.bccache.Bucket
|
|
|
:members: write_bytecode, load_bytecode, bytecode_from_string,
|
|
|
bytecode_to_string, reset
|
|
|
|
|
@@ -471,9 +471,9 @@ To use a bytecode cache, instanciate it and pass it to the :class:`Environment`.
|
|
|
|
|
|
Builtin bytecode caches:
|
|
|
|
|
|
-.. autoclass:: jinja2.FileSystemBytecodeCache
|
|
|
+.. autoclass:: ambari_jinja2.FileSystemBytecodeCache
|
|
|
|
|
|
-.. autoclass:: jinja2.MemcachedBytecodeCache
|
|
|
+.. autoclass:: ambari_jinja2.MemcachedBytecodeCache
|
|
|
|
|
|
|
|
|
Utilities
|
|
@@ -482,17 +482,17 @@ Utilities
|
|
|
These helper functions and classes are useful if you add custom filters or
|
|
|
functions to a Jinja2 environment.
|
|
|
|
|
|
-.. autofunction:: jinja2.environmentfilter
|
|
|
+.. autofunction:: ambari_jinja2.environmentfilter
|
|
|
|
|
|
-.. autofunction:: jinja2.contextfilter
|
|
|
+.. autofunction:: ambari_jinja2.contextfilter
|
|
|
|
|
|
-.. autofunction:: jinja2.evalcontextfilter
|
|
|
+.. autofunction:: ambari_jinja2.evalcontextfilter
|
|
|
|
|
|
-.. autofunction:: jinja2.environmentfunction
|
|
|
+.. autofunction:: ambari_jinja2.environmentfunction
|
|
|
|
|
|
-.. autofunction:: jinja2.contextfunction
|
|
|
+.. autofunction:: ambari_jinja2.contextfunction
|
|
|
|
|
|
-.. autofunction:: jinja2.evalcontextfunction
|
|
|
+.. autofunction:: ambari_jinja2.evalcontextfunction
|
|
|
|
|
|
.. function:: escape(s)
|
|
|
|
|
@@ -503,11 +503,11 @@ functions to a Jinja2 environment.
|
|
|
|
|
|
The return value is a :class:`Markup` string.
|
|
|
|
|
|
-.. autofunction:: jinja2.clear_caches
|
|
|
+.. autofunction:: ambari_jinja2.clear_caches
|
|
|
|
|
|
-.. autofunction:: jinja2.is_undefined
|
|
|
+.. autofunction:: ambari_jinja2.is_undefined
|
|
|
|
|
|
-.. autoclass:: jinja2.Markup([string])
|
|
|
+.. autoclass:: ambari_jinja2.Markup([string])
|
|
|
:members: escape, unescape, striptags
|
|
|
|
|
|
.. admonition:: Note
|
|
@@ -520,15 +520,15 @@ functions to a Jinja2 environment.
|
|
|
Exceptions
|
|
|
----------
|
|
|
|
|
|
-.. autoexception:: jinja2.TemplateError
|
|
|
+.. autoexception:: ambari_jinja2.TemplateError
|
|
|
|
|
|
-.. autoexception:: jinja2.UndefinedError
|
|
|
+.. autoexception:: ambari_jinja2.UndefinedError
|
|
|
|
|
|
-.. autoexception:: jinja2.TemplateNotFound
|
|
|
+.. autoexception:: ambari_jinja2.TemplateNotFound
|
|
|
|
|
|
-.. autoexception:: jinja2.TemplatesNotFound
|
|
|
+.. autoexception:: ambari_jinja2.TemplatesNotFound
|
|
|
|
|
|
-.. autoexception:: jinja2.TemplateSyntaxError
|
|
|
+.. autoexception:: ambari_jinja2.TemplateSyntaxError
|
|
|
|
|
|
.. attribute:: message
|
|
|
|
|
@@ -551,7 +551,7 @@ Exceptions
|
|
|
unicode strings is that Python 2.x is not using unicode for exceptions
|
|
|
and tracebacks as well as the compiler. This will change with Python 3.
|
|
|
|
|
|
-.. autoexception:: jinja2.TemplateAssertionError
|
|
|
+.. autoexception:: ambari_jinja2.TemplateAssertionError
|
|
|
|
|
|
|
|
|
.. _writing-filters:
|
|
@@ -593,7 +593,7 @@ paragraphs and marks the return value as safe HTML string if autoescaping is
|
|
|
enabled::
|
|
|
|
|
|
import re
|
|
|
- from jinja2 import environmentfilter, Markup, escape
|
|
|
+ from ambari_jinja2 import environmentfilter, Markup, escape
|
|
|
|
|
|
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')
|
|
|
|
|
@@ -659,7 +659,7 @@ must only happen with a :class:`nodes.EvalContextModifier` and
|
|
|
:class:`nodes.ScopedEvalContextModifier` from an extension, not on the
|
|
|
eval context object itself.
|
|
|
|
|
|
-.. autoclass:: jinja2.nodes.EvalContext
|
|
|
+.. autoclass:: ambari_jinja2.nodes.EvalContext
|
|
|
|
|
|
.. attribute:: autoescape
|
|
|
|
|
@@ -782,6 +782,6 @@ could help applications to implement more advanced template concepts. All
|
|
|
the functions of the meta API operate on an abstract syntax tree as
|
|
|
returned by the :meth:`Environment.parse` method.
|
|
|
|
|
|
-.. autofunction:: jinja2.meta.find_undeclared_variables
|
|
|
+.. autofunction:: ambari_jinja2.meta.find_undeclared_variables
|
|
|
|
|
|
-.. autofunction:: jinja2.meta.find_referenced_templates
|
|
|
+.. autofunction:: ambari_jinja2.meta.find_referenced_templates
|