fix: allow pug template inheritance#572
fix: allow pug template inheritance#572benblazak wants to merge 1 commit intosveltejs:mainfrom benblazak:main
Conversation
| // separate content that needs to come before the svelte mixins | ||
| let preContent = ''; | ||
|
|
||
| if (content.startsWith('extends')) { |
There was a problem hiding this comment.
Given the example of inheritance from pug's documentation, what do you think of also adding support for files that start with a comment?
//- page-a.pug
extends layout.pug
block scripts
script(src='/jquery.js')
script(src='/pets.js')|
Hey @benblazak, thanks for this! Just added a small suggestion 🙏 |
|
Ahh good catch @kaisermann. To properly allow comments though, we'd probably need to parse them (there can be more than one before Thinking about it, it might make more sense to stop including mixins by default at all, and put them in a separate file for people to include if they want. But that would be a breaking change. |
|
Fixed so that extends works with comments and (Machine translation from Japanese to English at DeepL) |
Fixes #459.
Allows for pug template inheritance.
The issue was that
extendsstatements must occur first in a pug file, but the svelte mixins were being inserted at the top of the file contents before being passed to pug.I made changes so that if an
extendsstatement occurs as the first line in a file, it is split off from the rest of the content and inserted before the svelte mixins.notes
I wasn't able to research or test whether there are other things that should also be kept before svelte mixins.