Base Section Templates

I’m developing section templates but in order to keep my code DRY, I want to use a base section that I can extend with blocks like I do for my base page template:

base seciton code

<!--
 templateType: section
 label: SECTION LABEL
 isAvailableForNewContent: false
-->
{% dnd_section 
 padding={
 'default': {
 'top': '8rem',
 'bottom': '8rem', 
 'left': '2rem',
 'right': '2rem'
 },
 'mobile': {
 'top': '2rem',
 'bottom': '2rem', 
 'left': '2rem',
 'right': '2rem'
 } 
 },
 background_color="#111317",
 max_width=1200,
 full_width=false
%}
 {% dnd_column %}
 {% dnd_row %}
 {% block module %}
 {% endblock %}
 {% end_dnd_row %}
 {% end_dnd_column %}
{% end_dnd_section %}

section code:

<!--
 templateType: section
 label: My custom section
 isAvailableForNewContent: true
-->
{% extends '../base/base-section.html' %}
{% block module %}
 <!-- module snippet here -->
{% end_dnd_module %}

However, I get the following error: The section can only have one root-level “dnd_section” tag.
Ideally, I would also be able to pass in an argument for the background color but I would like to get this work first if possible.

@EdCupaioli - I applaud the inventiveness here! Especially naviagtingthrough the inconsistent CMS documentation on section templates!

This may be another example of inconsistency but in a tutorial on the topic here:

The section template is included with the use of

{% include_dnd_partial path="../sections/testimonial.html" %}

rather than using the ‘block’ and ‘extends’ notation. Not sure I can determine which is the approved way to do this, especially where you want to add a class parameter.

Looking forward to understanding the final approach!

Steve

That just adds the section to a page template. I’m using extends with layouts and partials already, but there doesn’t seem like there’s a way to insert modules in sections with that same logic. I’m using theme settings fields to populate the padding, background, and max width now which does the job, but I was hoping to just have one master section I can invoke when I create sections with modules.

OK - you are way ahead of me in this setup. But I did have one thought - do you think that the overload of the use of ‘module’ as an identifier here could be problematic?

Steve