Forum Discussion

Malcolm-M's avatar
2 years ago

Change heading tag in core components

Other than resorting to javascript, aria or recreating the component from scratch is there a simple way to set the starting h tag level for a core component? For example I want a component to start at h3 NOT h2 as I've now nested it under a title which is h2.

  • There might be a "middle-ground", e.g. you don't have to recreate the component from scratch if you use @override 's for the native component. Assign the OOB component's output to a variable (capture the output of the OOB component) like this:

    <#assign oob>
        <@delegate />
    </#assign>


    Then you could simply replace h2's with h3's:

    <#assign output = oob?replace('h2', 'h3', 'rmi') />
    
    ${output}

     

    maybe you want to make the replacer a bit more sophisticated (e.g. use a proper regex), but I think for headings it should do...

    and of course you need to create the @override component, e.g. whatever component is rendering the headings (the native one) create a new one with the same name and add @override to the name. You won't have to do anything in quilts this way.

5 Replies

  • There might be a "middle-ground", e.g. you don't have to recreate the component from scratch if you use @override 's for the native component. Assign the OOB component's output to a variable (capture the output of the OOB component) like this:

    <#assign oob>
        <@delegate />
    </#assign>


    Then you could simply replace h2's with h3's:

    <#assign output = oob?replace('h2', 'h3', 'rmi') />
    
    ${output}

     

    maybe you want to make the replacer a bit more sophisticated (e.g. use a proper regex), but I think for headings it should do...

    and of course you need to create the @override component, e.g. whatever component is rendering the headings (the native one) create a new one with the same name and add @override to the name. You won't have to do anything in quilts this way.