Cascade is self-closing my empty sections!

thugsb's Avatar

thugsb

08 Oct, 2015 03:22 PM

I have a template with

<section class="intro"><system-region name="INTRO"/></section>

and sometimes the INTRO region is empty. When it is empty, I want Cascade to output

<section class="intro"></section>

but instead Cascade is outputting

<section class="intro" />

Unfortunately, section elements aren't allowed to be self-closing, and so the browser is then rendering subsequent elements as if they were inside the section.intro.

I could fix this by putting some whitespace into the template. However, I'd rather avoid doing that, as I'd like to be able to use section.intro:empty {display:none;} in my CSS (and that doesn't work if there's whitespace present).

Is there a way to tell Cascade to not self-close <section> elements?

  1. 1 Posted by ddent on 09 Oct, 2015 03:23 PM

    ddent's Avatar

    If you put a comment in the section Cascade won't auto-close the tag.

  2. 2 Posted by Ryan Griffith on 09 Oct, 2015 06:11 PM

    Ryan Griffith's Avatar

    Hi,

    As Dave mentioned, if you place some content (ie a comment or non-breaking space) into the <section> it won't be converted to self-closing.

    This behavior is due to a process used during XML serialization that expands specific tags. Specifically, there is a configuration file that determines what tags should be left expanded; otherwise, the tag will be converted to a self-closing tag. As you can see, this process does not have knowledge of what HTML tags are supposed to remain expanded.

    I went ahead and logged and improvement for this behavior and attached it to this discussion, which you can track in the upper right-hand corner of this discussion page. When the issue is being worked on or resolved, the issue will state that it is closed.

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by thugsb on 14 Oct, 2015 05:37 PM

    thugsb's Avatar

    Dave's fix works perfectly for now, thanks!

    <section class="intro"><!-- Intro --><system-region name="INTRO"/></section>
    
  4. thugsb closed this discussion on 14 Oct, 2015 05:37 PM.

  5. Tim closed this discussion on 29 Oct, 2015 06:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac