I am creating a theme template which has a drag and drop area. In this section will be placed a module. I also have a Theme Options settings page that allows the client to set a default padding on sections in the DND area (see attached image).
In the hubl code I know I can write:
{% dnd_section full_width=true, padding={'top': 60,'bottom': 60,'left': '0','right': '0'},vertical_alignment='MIDDLE' %}{% dnd_module path='/theme/theme-modules/module' %}{% end_dnd_module %}{% end_dnd_section %}
And I will see that the section in the page editor will have these values for padding.
When I attempt to write the content as:
{% dnd_section full_width=true, padding={'top': {{ theme.site_layout.section_top_bottom }},'bottom': {{ theme.site_layout.section_top_bottom }},'left': {{ theme.site_layout.body_padding }},'right': {{ theme.site_layout.body_padding }}},vertical_alignment='MIDDLE' %}{% dnd_module path='/template/template-modules/module' %}{% end_dnd_module %}{% end_dnd_section %}
I get an error from the CLI on upload
[ERROR] Error validating template.[ERROR] line 187: Error parsing '{'top': {{ theme.site_layout.section_top_bottom }},'bottom': {{ theme.site_layout.section_top_bottom }},'left': {{ theme.site_layout.body_padding }},'right': {{ theme.site_layout.body_padding }},}': {{ theme.site_layout.section_top_bottom }},'bottom': {{ theme.site_layout.section_top_bottom }},'left': {{ theme.site_layout.body_padding }},'right': {{ theme.site_layout.body_padding }},}}': syntax error at position 75, encountered '}', expected ':'
If I put the variable in quotation marks
'top': '{{ theme.site_layout.section_top_bottom }}',
The templae will upload without an error, however the section will not this padding when I create a new page.
I also tried adding a suffix as well
'top': '{{ theme.site_layout.section_top_bottom }}px',
This did not work.
If I set to just print the variable to the page, I will get the value ‘120’ and so I know the variable is being passed to the template.
If I send a different variable to another field, it will work
max_width= {{ theme.site_layout.maximum_content_width }},
I am thinking it has something to do with the padding json formatting but I can quite figure it out.
I am currently passing these values through a custom CSS file as
.body-container-wrapper .body-container .dnd-section { padding-left: {{ theme.site_layout.body_padding }}px; padding-right: {{ theme.site_layout.body_padding }}px; }
but this isn’t ideal as there are some modules that need to be fullwidth without padding left and right while other modules that require that padding.
Any thoughts on this appreciated.