Skip to content

Support CSS files for style tags and attributes #89

@npeltier

Description

@npeltier

original message in https://lists.apache.org/thread.html/rbf853d99ccdb7e4259231abfcfc11e9c4469ced6095e859027ba4ed2%40%3Cdev.sling.apache.org%3E

certain components require that we overcome beautiful concept of separation
of concern between CSS & HTML as variability of the potential styling is
too high.
This makes us developer forced to add style tag or attribute, together with
inner htl scripting logic, that has been designed to template HTML, but is
a bit too loud for CSS rules.
My proposal is that we extend HTL only for that purpose to parse CSS files
that could be included in style tag or attributes, with similar loop & if
logic, maybe in a different syntax to keep the CSS valid, so to have
something like [0]. Please consider proposed syntax as symbolic, we can
discuss that later if there is an agreement on the proposal itself.
We could also have existing css compilers like less or sass but that might
be overkill and this would lead to lot of frustration as we wouldn't
implement everything.

result would be inline css in style tag / attribute (so only HTML, cf. #89 (comment))

[0]
OLD (not counting the CSS in the models):
<style>
<sly data-sly-repeat.item="${model.definitions}">
${'#{0}' @ format=model.id, context='styleString'} > .items {
<sly data-sly-test.output="${item.show}">
  ${definition.width}
  ${definition.minHeight}
  ${definition.order}
</sly>
}
<sly>
</style>

NEW:
<style data-sly-include="style.css"/>
and
style.css:
# sly-repeat.item="${model.definitions}"
  #'$model-id' > .items {
    # sly-test.output="${item.show}
    width: $item-width;
    min-height: $item-minHeight;
    order: $item-order
    # /sly
}
# /sly```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions