PhilipFlyvholm / Terrier

Terrier is a new web application compiler inspired by Svelte and Pug to give an alternative syntax to html while still having the benefits of a component based compiler.
MIT License
4 stars 0 forks source link

Frontmatter script and style specification change #16

Open PhilipFlyvholm opened 1 year ago

PhilipFlyvholm commented 1 year ago

Since the point of Terrier is to make as clean code as possible then I would make a suggestion for a specification change to change from the current

@script{
    const spec = "old spec";
}

To a frontmatter styled implementation:

-- js --
const spec = "new spec";
--------

This implementation removes the unnecessary indent for the javascript code. The javascript processor can even be given on the top line. A full example would look like this:

-- js --

import "../style.css";
const hello = "Terrier";

--------

h1 class="text-3xl bold" > {hello}

Scoped styles could also be implemented like this. Such as:

-- js --

import "../style.css";
const hello = "Terrier";

-- CSS --
.bold{
    font-weight: bold;
}
--------

h1 class="text-3xl bold" > {hello}

This means that if you want a scoped style then you use the frontmatter version while a normal "global" style would be implemented using the default style element.

In the above case the css section continues on the end of the script section instead of having two lines of --- after each other.

PhilipFlyvholm commented 11 months ago

Alt syntax:

-------- js
const spec = "new spec";
--------
-------- js

import "../style.css";
const hello = "Terrier";

-------- css
.bold{
    font-weight: bold;
}
--------
h1 class="text-3xl bold" > {hello}