webpackpugjssvelte

Is there a way to use pugjs in svelte components?


I'm trying to rewrite my app made with pugjs and express in sveltejs. I really like to write html in pugjs. I was wondering if there is anyway I can use pugjs in svelte components. I am assuming I may need to use svelte-loader and do some preprocessing or is that even possible? I'm using Sapper to rewrite my application in svelte. Can anyone help me how to do that in Sapper?


Solution

  • I haven't used pug before, but i figure as long as you don't want to translate the pug template into a svelte component (where f.i. pug iteration would be turned into svelte iteration).

    So if you can make your pug template a valid svelte component, you should be able to good to go. So including the script tag with logic, and in the outputted html have the {#if|each|await} blocks and {interpolation} blocks.