#svelte #html #js #compile #parser #expressrs

svelte-parser

Compile Svelte code into HTML, JS for expressrs

2 releases

0.1.3 Jul 6, 2024
0.1.2 Jul 6, 2024
0.1.1 Jul 5, 2024
0.1.0 Jul 5, 2024

#1860 in Web programming

Download history 7/week @ 2024-07-24 1/week @ 2024-07-31 4/week @ 2024-09-11 2/week @ 2024-09-25 3/week @ 2024-10-02

60 downloads per month

AGPL-1.0-only

10KB
251 lines

Svelte Parser

a Svelte Parser for the expressrs crate.

Svelte Example

@.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>

How can i use this?

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(),
        }),
    );
}

Dependencies

~0.7–1.6MB
~35K SLoC