The Jewel Theme wants to add a <link> element to the HTML to bring in a
font.  The <inject_html> directive was introduced to add elements to the
HTML needed for code in the class decorated by the <inject_html>.   Jewel
is using a dummy class with <inject_html> which probably means that the AS
code doesn't need the link element, but the CSS in the theme does.

IMO, that means that there should be a directive in CSS that also injects
html.  I don't think comments are retained in CSS, so using inject_html in
a comment is not something I would recommend.  IMO, the directive should
be on/in the selectors that need it, and not at the file level.

One way to do this would be a fake media-query like:

@media -inject_html

That could contain selectors with fake properties like:

Button {
 foo: <link .... />
}

If a Button is used in the app, then the compiler would see the Button
selector in the -inject_html media, and inject the html for every property
in the selector.  IOW, if you did:

Button {
  foo: <link .... />
  bar: <style ... />
}

Then both link and style would be injected into the output HTML.

Another approach would be to introduce a special inject_html property that
you would use in the selector as needed.  So, if Button sets
font-family="Lato" it would also set inject_html like below:

Button {
  font-family: Lato;
  inject-html: <link ... />
}


This has the advantage of keeping the links with the font-family that
needs it, but you will have to duplicate inject-html in each of the
selectors that need it.

Other ideas are welcome.  Thoughts?
-Alex

Reply via email to