summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2016-04-21 14:23:22 +0200
committerOlivier Dony <odo@openerp.com>2016-04-27 16:47:51 +0200
commit679f14dc5950c340023cfda2a001fc106232de6c (patch)
tree4531389c2f117e75c982e2aa9d00125adfb864e7 /doc/reference
parentbb8f0f1fc3d0f5574938019ca69cc917a55e7962 (diff)
[ADD] base: view inheritance with wrapping support
When using the inheritance spec `position="replace"`, the framework will now support a text node exactly equal to `$0` and will replace it with the node that was matched by the inheritance locator. Given an original view equal to this: ``` <div class="foo"> <p class="bar">the paragraph</p> </div> ``` And an inherited view with the following inheritance spec: ``` <p class="bar" position="replace"> <div class="panel"> <div class="panel-header">The Title</div> <div class="panel-body"> $0 </div> </div> </p> ``` The finalt result after inheritance would become: ``` <div class="foo"> <div class="panel"> <div class="panel-header">The Title</div> <div class="panel-body"> <p class="bar">the paragraph</p> </div> </div> </div> ``` Also updated doc and tests accordingly.
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/views.rst17
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/reference/views.rst b/doc/reference/views.rst
index 3c8eaa02126..6bed888f571 100644
--- a/doc/reference/views.rst
+++ b/doc/reference/views.rst
@@ -76,15 +76,19 @@ The result of applying children views yields the final ``arch``
Inheritance specs
-----------------
-There are three types of inheritance specs:
+Inheritance specs are comprised of an element locator, to match
+the inherited element in the parent view, and children element that
+will be used to modify the inherited element.
+
+There are three types of element locators for matching a target element:
* An ``xpath`` element with an ``expr`` attribute. ``expr`` is an XPath_
expression\ [#hasclass]_ applied to the current ``arch``, the first node
it finds is the match
* a ``field`` element with a ``name`` attribute, matches the first ``field``
- with the same ``name``
-* any other element, the first element with the same name and identical
- attributes (ignoring ``position``) is matched
+ with the same ``name``. All other attributes are ignored during matching
+* any other element: the first element with the same name and identical
+ attributes (ignoring ``position`` and ``version`` attributes) is matched
The inheritance spec may have an optional ``position`` attribute specifying
how the matched node should be altered:
@@ -92,7 +96,10 @@ how the matched node should be altered:
``inside`` (default)
the content of the inheritance spec is appended to the matched node
``replace``
- the content of the inheritance spec replaces the matched node
+ the content of the inheritance spec replaces the matched node.
+ Any text node containing only `$0` within the contents of the spec will
+ be replaced by a complete copy of the matched node, effectively wrapping
+ the matched node.
``after``
the content of the inheritance spec is added to the matched node's
parent, after the matched node