Style and Script Blocks
CurveaScript supports inline CSS and JavaScript blocks.
Style block
@style
.hero {
padding: 4rem 1.5rem;
}
@end
The CSS is collected during rendering and injected into the final document head.
Script block
@script
console.log("Page loaded")
@end
The JavaScript is collected during rendering and injected near the end of the body.
Where blocks can be used
The parser supports @style and @script blocks at top-level flow depth in:
- pages
- layouts
- components
- documents
Deduplication
Resolved styles and scripts are deduplicated by exact string value.
Use cases
Inline blocks are useful for small page-specific or component-specific behavior.
For larger CSS and JavaScript, use files in:
src/assets/css
src/assets/js
Closing rule
Both blocks must close with:
@end