I just stumbled upon the 'Field Templates'-function in the glorious Display suite-Module.

For everyone who doesn't know it: This function makes it possible to completely redefine how a a field gets rendered. Field-wrappers, item-wrappers and their classes.

with a lot of configuration you can get a neat clean result like this:

<div class="ds-2col-stacked node view-mode-teaser clearfix">
      <div class="group-left">
        <h2><a href="/node/123">Lorem ipsum dolor sit amet</a></h2>
        <p class="lead"><strong class="even">Consectetur adipisicing elit, sed do eiusmod tempor  .</strong></p>
      </div>
  
      <div class="group-right">
      <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
      <div class="field field-name-node-link"><a href="/node/123">Read more</a></div></div>
  </div>

I think something like this should be default instead of code that is about a third larger and about 70% more useless. The simple structure also makes css much more easier. simple things like .group-left p:first-child{margin-top:0;} doesn't make much sense in drupal default output.

contrary to the ds solution I think this shouldn't be possible to change in the backend by default. Site-builders (non-themers and coders) shouldn't be forced to care about html, css or even javascript. the produced code must work with all modules and themes. modules and themes sometimes depend on a specificity structured output.

So, who should be able to force an object to have a certain class or wrapper?

  • Themers
    When a theme needs a certain Markup to be present to work with its css, it should be able to force a specific object to have a certain wrapper and/or class.
  • Module developers/UI
    Also module developers should be able to wrap objects and to apply classes to make sure that all DOM-manipulation works properly

I know this is not exactly a bug report, its an appeal to discuss about the current design philosophy and work flow. I'm sure, this is not the only issue about this topic but I couldn't anything similar. sorry, if this is going to be a duplicate^^

Comments

star-szr’s picture

Issue summary: View changes
Status: Active » Fixed

I think we actually kinda did this now that we have Stable and Classy base themes in core :)

#2575421: Add a Stable base theme to core and make it the default if a base theme is not specified
https://www.drupal.org/theme-guide/8/classy

If you just create a normal base theme not extending Classy you'll end up with a lot fewer divs, classes, etc.!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.