sveltecli/
templates.rs

1pub fn error_svelte() -> &'static str {
2    return "<script lang=\"ts\">
3  import { page } from '$app/stores';
4</script>
5
6<h1>{$page.status}: {$page.error.message}</h1>";
7}
8
9pub fn error_svelte_js() -> &'static str {
10    return "<script>
11  import { page } from '$app/stores';
12</script>
13
14<h1>{$page.status}: {$page.error.message}</h1>";
15}
16
17pub fn layout_svelte() -> &'static str {
18    return "<script lang=\"ts\">
19    import type { LayoutData } from \"./$types\";
20
21    export let data: LayoutData;
22</script>
23
24<slot />";
25}
26
27pub fn layout_svelte_js() -> &'static str {
28    return "<script>
29    export let data;
30</script>
31
32<slot />";
33}
34
35pub fn layout_client() -> &'static str {
36    return "import type { LayoutLoad } from \"./$types\";
37
38export const load = (({ }) => {
39    return {};
40}) satisfies LayoutLoad;";
41}
42
43pub fn layout_client_js() -> &'static str {
44    return "export const load = ({ }) => {
45    return {};
46}";
47}
48
49pub fn layout_server() -> &'static str {
50    return "import type { LayoutServerLoad } from \"./$types\";
51
52export const load = (({ }) => {
53    return {};
54}) satisfies LayoutServerLoad;";
55}
56
57pub fn layout_server_js() -> &'static str {
58    return "export const load = ({ }) => {
59    return {};
60}";
61}
62
63pub fn page_svelte() -> &'static str {
64    return "<script lang=\"ts\">
65    import type { PageData } from \"./$types\";
66
67    export let data: PageData;
68</script>
69
70<h1>Page</h1>";
71}
72
73pub fn page_svelte_js() -> &'static str {
74    return "<script>
75    export let data: PageData;
76</script>
77
78<h1>Page</h1>";
79}
80
81pub fn page_client() -> &'static str {
82    return "import type { PageLoad } from \"./$types\";
83
84export const load = (({ }) => {
85    return {};
86}) satisfies PageLoad;";
87}
88
89pub fn page_client_js() -> &'static str {
90    return "export const load = ({ }) => {
91    return {};
92}";
93}
94
95pub fn page_server() -> &'static str {
96    return "import type { Actions, PageServerLoad } from \"./$types\";
97
98export const load = (({ }) => {
99    return {};
100}) satisfies PageServerLoad;
101
102export const actions = {
103    formAction: async ({ request }) => {
104        const form = await request.formData();
105        const id = form.get('id');
106
107        return { id };
108    },
109} satisfies Actions;";
110}
111
112pub fn page_server_js() -> &'static str {
113    return "export const load = ({ }) => {
114    return {};
115};
116
117export const actions = {
118    formAction: async ({ request }) => {
119        const form = await request.formData();
120        const id = form.get('id');
121
122        return { id };
123    },
124};";
125}
126
127pub fn server() -> &'static str {
128    return "import type { RequestHandler } from \"./$types\";
129
130export const GET = ( ({ url }) => {
131    return new Response(String(url));
132}) satisfies RequestHandler;";
133}
134
135pub fn server_js() -> &'static str {
136    return "export const GET = ({ url }) => {
137    return new Response(String(url));
138};";
139}