From 338a4da821b43de7e89d57681b66baa76749ab6d Mon Sep 17 00:00:00 2001 From: Michael Graf Date: Wed, 12 Jun 2019 09:33:43 +0200 Subject: [PATCH] prepare for callable data-attributes, for bluedynamics/yafowil.plone#26 --- HISTORY.rst | 4 +++- src/yafowil/yaml/parser.py | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index ff3c535..2d00eb1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,7 +5,9 @@ History 1.4 (unreleased) ---------------- -- No changes yet. +- Parse values of attributes (data-Attributes) if type() is dict. + HTML5 Data-Attributes with i18n or callables are possible now + [2silver, 2019-06-12] 1.3 (2018-07-16) diff --git a/src/yafowil/yaml/parser.py b/src/yafowil/yaml/parser.py index 73dc8cc..8e8e2c1 100644 --- a/src/yafowil/yaml/parser.py +++ b/src/yafowil/yaml/parser.py @@ -98,7 +98,15 @@ def create_tree(self, data): def call_factory(defs): props = dict() for k, v in defs.get('props', dict()).items(): - props[k] = self.parse_definition_value(v) + if isinstance(v, dict): + dict_attrs = list() + for vk, vv in v.items(): + val = self.parse_definition_value(vv) + part = [vk, val] + dict_attrs.append(part) + props[k] = dict_attrs + else: + props[k] = self.parse_definition_value(v) custom = dict() for custom_key, custom_value in defs.get('custom', dict()).items(): custom_props = list()