Skip to content

Parse callable Tag-Attributes#40

Open
2silver wants to merge 1 commit intoconestack:masterfrom
2silver:data-attributes-callable
Open

Parse callable Tag-Attributes#40
2silver wants to merge 1 commit intoconestack:masterfrom
2silver:data-attributes-callable

Conversation

@2silver
Copy link

@2silver 2silver commented Jun 12, 2019

Makes it possible to parse expressions or i18n-attributes.
For bluedynamics/yafowil.plone#26

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.5% when pulling 011b2f5 on 2silver:data-attributes-callable into b977650 on bluedynamics:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.5% when pulling 011b2f5 on 2silver:data-attributes-callable into b977650 on bluedynamics:master.

@rnixx
Copy link
Member

rnixx commented Jun 12, 2019

Hi,

all the translation is done in yafowil.utils.Tag.__call__. I'd suggest to implement it there.

https://github.com/bluedynamics/yafowil/blob/master/src/yafowil/utils.py#L128
https://github.com/bluedynamics/yafowil/blob/master/src/yafowil/utils.py#L152

We need to check for dicts and probably lists here and do a modification of the inner values recursively.
There's some chance that we need to adopt yafowil.yaml, but i'm almost sure the i18n translation strings are created properly there inside data dicts.

@2silver
Copy link
Author

2silver commented Jun 12, 2019

We need to check for dicts and probably lists here and do a modification of the inner values recursively.
There's some chance that we need to adopt yafowil.yaml, but i'm almost sure the i18n translation strings are created properly there inside data dicts.

Yes, but only if Dict-Like attributes are parsed recursivly, please see conestack/yafowil.yaml#6

This commit here is only for expressions in dict-like attributes

@rnixx
Copy link
Member

rnixx commented Jun 12, 2019

This commit here is only for expressions in dict-like attributes

Take a look what callback gets generated from expr: here https://github.com/bluedynamics/yafowil.yaml/blob/master/src/yafowil/yaml/parser.py#L153. The proper call for fetching the value then would be yafowil.utils.callable_value, but this expects widget and runtime data instances as arguments. So we would need to change as_data_attrs signature. A short grep through my dev setup shows that as_data_attrs is used in yafowil package and in yafowil.widget.richtext. And if we change the signature the code should be consolidated with yafowil.utils.data_attrs_helper.

@rnixx
Copy link
Member

rnixx commented Jun 12, 2019

btw - you can checkout yafowil.demo and run it's buildout if you need a full yafowil development setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants