Giter Club home page Giter Club logo

Comments (6)

bluwy avatar bluwy commented on July 18, 2024

I think it's more that the compiler always expect CSS syntax in the <style> tag, so it sees the children as CSS and doesn't do JSX style interpolation. set:html seems like the better way for me.

from astro.

matthewp avatar matthewp commented on July 18, 2024

set:html does work, but I would expect that passing a string as a child to be escaped just like passing a string to any child tag. So I do think this is a case of the compiler having an issue specifically with style tags.

from astro.

matthewp avatar matthewp commented on July 18, 2024

(context is that we were talking about removing define:vars possibly in 5.0 and this seems like a fine alternative, hopefully an idea you would like @bluwy 😀)

from astro.

bluwy avatar bluwy commented on July 18, 2024

Sorry misclosed whle switching tab 😅 Typing my proper comment next

from astro.

bluwy avatar bluwy commented on July 18, 2024

If we have the compiler allowing {} within style tags, and also CSS syntax, wouldn't it be ambiguous when parsing? Unless we hardcode checking {` as the first character.

I'm open to re-thinking how interpolating vars work though. I think the ideal way is something like this?

<style is:inline>
  h1 {
    color: ${color};
  }
</style>

So you can use normal CSS syntax, and easily interpolate variables. I wrote an RFC for Svelte before (which didn't go through), but the conclusion was the same v-bind syntax as Vue as it's valid CSS syntax. We also get better syntax highlighting this way.

from astro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.