Skip to content

Commit

Permalink
fix: add pug mixins to support svelte-5 syntax (#654)
Browse files Browse the repository at this point in the history
* support for svelte-5 #snippet and @render

* Update preprocessing.md
  • Loading branch information
5P5 authored Sep 9, 2024
1 parent 359b1f6 commit 9d49f3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Apart from those, the Pug preprocessor accepts:

**Template blocks:**

Some of Svelte's template syntax is invalid in Pug. `svelte-preprocess` provides some pug mixins to represent svelte's `{#...}{/...}` blocks: `+if()`, `+else()`, `+elseif()`, `+each()`, `+key()`, `+await()`, `+then()`, `+catch()`, `+html()`, `+const()`, `+debug()`.
Some of Svelte's template syntax is invalid in Pug. `svelte-preprocess` provides some pug mixins to represent svelte's `{#...}{/...}` and `{@...}` blocks: `+if()`, `+else()`, `+elseif()`, `+each()`, `+key()`, `+await()`, `+then()`, `+catch()`, `+html()`, `+const()`, `+debug()`, `+snippet()`, `+render()`.

```pug
ul
Expand Down
10 changes: 9 additions & 1 deletion src/transformers/pug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ mixin const(expression)
%_| {@const !{expression}}
mixin debug(variables)
%_| {@debug !{variables}}`.replace(
%_| {@debug !{variables}}
mixin snippet(expression)
%_| {#snippet !{expression}}
%_block
%_| {/snippet}
mixin render(expression)
%_| {@render !{expression}}`.replace(
/%_/g,
indentationType === 'tab' ? '\t' : ' ',
);
Expand Down

0 comments on commit 9d49f3d

Please sign in to comment.