|
1 | 1 | <script lang="ts">
|
2 | 2 | import { Checkbox } from '@sveltejs/site-kit/components';
|
3 | 3 | import type { Workspace } from '../Workspace.svelte';
|
| 4 | + import { get_repl_context } from '../../lib/context.js'; |
| 5 | +
|
| 6 | + const { svelteVersion } = $derived(get_repl_context()); |
| 7 | +
|
| 8 | + const is_fragments_available = $derived.by(() => { |
| 9 | + const [major, minor] = svelteVersion.split('.'); |
| 10 | + // if the version is 5.33.0 or greater, fragments are available |
| 11 | + if (+major >= 5 && +minor >= 33) { |
| 12 | + return true; |
| 13 | + } |
| 14 | + // we assume they are available if work with local |
| 15 | + return svelteVersion === 'local'; |
| 16 | + }); |
4 | 17 |
|
5 | 18 | let { workspace }: { workspace: Workspace } = $props();
|
6 | 19 | </script>
|
|
23 | 36 | <label for={generate}><span class="string">"{generate}"</span></label>
|
24 | 37 | {/each},
|
25 | 38 | </div>
|
26 |
| - |
27 |
| - <div class="option"> |
28 |
| - <span class="key">templatingMode:</span> |
29 |
| - |
30 |
| - {#each ['string', 'functional'] as const as templating_mode} |
31 |
| - <input |
32 |
| - id={templating_mode} |
33 |
| - type="radio" |
34 |
| - checked={workspace.compiler_options.templatingMode === templating_mode} |
35 |
| - value={templating_mode} |
36 |
| - onchange={() => { |
37 |
| - workspace.update_compiler_options({ templatingMode: templating_mode }); |
38 |
| - }} |
39 |
| - /> |
40 |
| - <label for={templating_mode}><span class="string">"{templating_mode}"</span></label> |
41 |
| - {/each}, |
42 |
| - </div> |
| 39 | + {#if is_fragments_available} |
| 40 | + <div class="option"> |
| 41 | + <span class="key">fragments:</span> |
| 42 | + |
| 43 | + {#each ['html', 'tree'] as const as templating_mode} |
| 44 | + <input |
| 45 | + id={templating_mode} |
| 46 | + type="radio" |
| 47 | + checked={workspace.compiler_options.fragments === templating_mode} |
| 48 | + value={templating_mode} |
| 49 | + onchange={() => { |
| 50 | + workspace.update_compiler_options({ fragments: templating_mode }); |
| 51 | + }} |
| 52 | + /> |
| 53 | + <label for={templating_mode}><span class="string">"{templating_mode}"</span></label> |
| 54 | + {/each}, |
| 55 | + </div> |
| 56 | + {/if} |
43 | 57 |
|
44 | 58 | <!-- svelte-ignore a11y_label_has_associated_control (TODO this warning should probably be disabled if there's a component)-->
|
45 | 59 | <label class="option">
|
|
0 commit comments