diff --git a/CHANGES.rst b/CHANGES.rst index 249345b..ceffc63 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,8 @@ History 2.2.1 (unreleased) ------------------ -- No chnages yet. +- When creating a blueprint chain with a factory, allow blueprints defined after blueprints based in ``generic_input_renderer``. + [thet] 2.2 (2016-10-06) diff --git a/src/yafowil/common.py b/src/yafowil/common.py index 6dbcf13..8769836 100644 --- a/src/yafowil/common.py +++ b/src/yafowil/common.py @@ -309,12 +309,17 @@ def input_attributes_full(widget, data, value=None): @managedprops(*css_managed_props) -def input_generic_renderer(widget, data, custom_attrs={}): +def input_generic_renderer(widget, data, pos='before', custom_attrs={}): """Generic HTML ``input`` tag render. """ input_attrs = input_attributes_full(widget, data) input_attrs.update(custom_attrs) - return data.tag('input', **input_attrs) + rendered = data.tag('input', **input_attrs) + if pos == 'before': + rendered = rendered + (data.rendered or u'') + else: + rendered = (data.rendered or u'') + rendered + return rendered # multivalued is not documented, because its only valid for specific blueprints @@ -333,7 +338,7 @@ def display_proxy_renderer(widget, data): input_attrs = input_attributes_full(widget, data, value=val) rendered += data.tag('input', **input_attrs) else: - rendered += input_generic_renderer(widget, data) + rendered = input_generic_renderer(widget, data, pos='after') if orgin_type: widget.attrs['type'] = orgin_type else: @@ -389,10 +394,11 @@ def generic_positional_rendering_helper(tagname, message, attrs, rendered, pos, pos position how to place the newtag relative to the prior rendered: 'before'='messagerendered', - 'after' ='message' + 'after' ='renderedmessage' 'inner-before'= message rendered 'inner-after'= rendered message """ + rendered = rendered or u'' if pos not in ['before', 'after', 'inner-before', 'inner-after']: raise ValueError('Invalid value for position "{0}"'.format(pos)) if pos.startswith('inner'): diff --git a/src/yafowil/common.rst b/src/yafowil/common.rst index a1ee33b..1d9ab95 100644 --- a/src/yafowil/common.rst +++ b/src/yafowil/common.rst @@ -449,8 +449,7 @@ hidden field:: >>> wrapped_pxml(widget())
lorem ipsum
- +
@@ -470,6 +469,23 @@ Skip mode renders empty string.:: >>> widget() u'' +Multiple blueprints:: + + >>> widget = factory( + ... 'label:text:help', + ... name="textinput", + ... props={ + ... 'label': 'label before input', + ... 'help': 'help after input', + ... } + ... ) + >>> wrapped_pxml(widget()) +
+ + +
help after input
+
+ Datatype extraction -------------------