From 707206f7457cf5e066c95a18d3f99f48ea61481d Mon Sep 17 00:00:00 2001 From: Misha Zamkevich Date: Mon, 5 Oct 2020 21:51:09 +1000 Subject: [PATCH] feat: add new syntax {key} for `pug` (#259) --- docs/preprocessing.md | 2 +- src/transformers/pug.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/preprocessing.md b/docs/preprocessing.md index 26597288..a9f36854 100644 --- a/docs/preprocessing.md +++ b/docs/preprocessing.md @@ -297,7 +297,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()`, `+await()`, `+then()`, `+catch()`, `+html()`, `+debug()`. +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()`, `+debug()`. ```pug ul diff --git a/src/transformers/pug.ts b/src/transformers/pug.ts index 3303efce..7f4ad1af 100644 --- a/src/transformers/pug.ts +++ b/src/transformers/pug.ts @@ -18,6 +18,11 @@ mixin elseif(condition) %_| {:else if !{condition}} %_block +mixin key(expression) +%_| {#key !{expression}} +%_block +%_| {/key} + mixin each(loop) %_| {#each !{loop}} %_block