question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change $layout.svelte to @layout.svelte and [param].svelte to {param}.svelte?

See original GitHub issue

Ok hear me out.

I think we closed https://github.com/sveltejs/kit/issues/894 prematurely; it does make sense to use a character that doesn’t require special handling, if possible. It’s awkward to type src/routes/$layout.svelte on the command line — you get to the $ and either have to reach for the backslash, or curse your lack of forethought in not typing 'src (single quote only, no doubles!) instead of src.

Even if you don’t find yourself typing/tab-completing route filenames on the command line frequently, you might find yourself attempting to cmd-click on the filename in your editor’s integrated terminal (e.g. in the output from git diff or tsc or whatever) in order to edit the file. At least in VSCode, that doesn’t work for filenames containing $layout, probably because something somewhere is replacing it with the layout environment variable.

These problems go away with @.

Related to the cmd-click problem: VSCode doesn’t recognise this as a file — if you hover it, it will only highlight the file up to the [ character:

image

image

This, on the other hand…

image

…works perfectly:

image

I should note that this behaviour appears to be specific to VSCode; iTerm reverses the treatment of [bar] and {bar}. But I think it’s probably more important that cmd-click works in integrated editor terminals, and VSCode is the most popular one of the bunch.

Aesthetically, @layout.svelte and @error.svelte seem fine, and I actually prefer {param} to [param], not least because it’s more aligned with the syntax of Svelte itself.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:45 (40 by maintainers)

github_iconTop GitHub Comments

7reactions
Rich-Harriscommented, Apr 20, 2021

windows: pissing in the punchbowl since 1985

2reactions
arxpoeticacommented, Apr 20, 2021

Honestly, I’m leaning more toward this being a “bug” with IDEs / terminals that provide clickable links. I no longer favor ~ tilde, happy little wave that it is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced routing • Docs • SvelteKit
If the pathname doesn't match, SvelteKit will try to match other routes (using the sort ... By default, the layout hierarchy mirrors the...
Read more >
Routing • Docs • SvelteKit
In turn, annotating the load function with PageLoad , PageServerLoad , LayoutLoad or LayoutServerLoad (for +page.js , +page.server.js , +layout.js and +layout.
Read more >
Loading data • Docs • SvelteKit
Before a +page.svelte component (and its containing +layout.svelte components) can be rendered, we often need to get some data. This is done by...
Read more >
Introduction • Docs • SvelteKit
Read the introduction to Svelte blog post and the Svelte tutorial to learn more.
Read more >
Docs • Svelte
SvelteKit will handle calling the Svelte compiler to convert your .svelte files into .js files that create the DOM and .css files that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found