Doing it Wrong #1: Using CSS to Render Content
by jsn1nj4
HTML
<article class="event" id="awesome_regional_conference-2023">
<h1 class="title"></h1>
<h3 class="date"></h3>
<p class="venue"></p>
<p class="location"></p>
</article>
SCSS
@mixin before($labels...) {
@for $i from 0 to length($labels) {
.#{nth($labels, $i + 1)}::before { content: var(--#{nth($labels, $i + 1)}) }
}
}
.event {
@include before("title", "date", "venue", "location");
&#awesome_regional_conference-2023 {
--title: "Awesome Regional Conference 2023";
--date: "5/21/2023";
--venue: "Totally Real Conference Hall";
--location: "123 Totally Real Blvd, Austin, Tx";
}
}