Comments (6)
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.
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.
(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.
Sorry misclosed whle switching tab 😅 Typing my proper comment next
from astro.
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)
- Issue with rendering HTML component as a Astro component's child. [email protected] | @astrojs/[email protected] HOT 5
- Assets imported through seed files points to incorrect URL in prod
- [Container API] Unable to pass props to container.renderToString HOT 1
- Astro:db Seed File Fails to be Loaded | "Failed to load url" HOT 2
- Updating to [email protected] throws errors HOT 3
- Astro update check breaks `astro dev` if offline HOT 2
- `<a>` as first element inside component breaks layout HOT 1
- style define:vars not working on child component HOT 1
- shikiConfig not applying to Code components outside markdown HOT 6
- Base does not change href value in anchors. HOT 4
- lit client-shim uses deprecated apis, throws page speed error HOT 4
- Relative paths configuration is broken HOT 3
- <Picture> element inflates image sizes HOT 2
- Incorrect TS error on Astro.redirect HOT 1
- I try to add images in my project, but report error on MAC M1. The error is "illegal hardware instruction". HOT 5
- Blending page layout scripts and post scripts HOT 2
- Possible bug: pages can update Astro.locals HOT 14
- i18n getAbsoluteLocaleUrl only respect parts of the astro.config.mjs config in vite tests HOT 3
- Table of Contents not generated automatically in Astro components HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from astro.