diazo icon indicating copy to clipboard operation
diazo copied to clipboard

Add convenience css:theme="" for same id in content

Open davilima6 opened this issue 8 years ago • 0 comments

This suggestion follows the DRY mindset. The idea is that a rule like this:

<replace
    css:content-children="#global_statusmessage"
    css:theme-children="#global_statusmessage"
    />

Could be written like this:

<replace css:content-children="#global_statusmessage" css:theme-children="" />

This is inspired in empty if-content="" syntax.

More cases:

<replace css:content-children="#global_statusmessage" css:theme="" />

Which translates to:

    <replace
        css:content-children="#global_statusmessage"
        css:theme="#global_statusmessage"
        />

And also:

<replace css:content="" css:theme="#global_statusmessage" />

Meaning:

<replace
    css:content="#global_statusmessage"
    css:theme="#global_statusmessage"
    />

While we'll be by no means enforcing anything, this has the added benefit of encouraging the best practice of renaming theme elements with the same IDs/classes as their contents' counterparts, which increases understandability of the transformations happening and thus maintainability.

Going further we could also allow one of the attributes to be omitted.

Risks:

  • Making code more cryptic (that's only if you didn't read the docs, same for if-content, I guess)
  • Forgetting to write a selector/attribute leads to unexpected behavior (idem)

davilima6 avatar Jun 10 '16 17:06 davilima6