| Crates.io | svelte-parser |
| lib.rs | svelte-parser |
| version | 0.1.3 |
| created_at | 2024-07-05 21:26:05.209303+00 |
| updated_at | 2024-07-06 14:24:41.246447+00 |
| description | Compile Svelte code into HTML, JS for expressrs |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1293411 |
| size | 10,071 |
a Svelte Parser for the expressrs crate.
@.svelte (AKA the main route /)
<script lang="ts">
const username: string = "Test";
console.log(username);
</script>
<title>Custom page title (Fallback will be the file's name)</title>
<p>Hello world!</p>
First you'll need to install the expressrs crate
then in your code type this:
use expressrs::ExpressLib;
use svelte_parser::svelte;
fn main() {
let express = ExpressLib::new();
let app = express();
app.plugins.push(svelte());
// Serve a directory called 'public' that has .svelte files
app.serve_directory(
"public",
Some(DirectoryOptions {
plugin: "svelte".to_string(),
}),
);
}