A Pug template language plugin for Vue Language Tools, enabling the use of <template lang="pug"> in Vue SFCs.
npm install @vue/language-plugin-pug --save-devAdd this plugin in tsconfig.json:
After configuration, you can use Pug syntax in Vue components:
<template lang="pug">
div.container
h1 {{ title }}
p {{ description }}
button(@click="handleClick") Click me
</template>
<script setup lang="ts">
const title = 'Hello'
const description = 'World'
const handleClick = () => console.log('clicked')
</script>This plugin implements the VueLanguagePlugin interface, providing:
getEmbeddedCodes- Identifies<template lang="pug">blocksresolveEmbeddedCode- Extracts Pug content as embedded codecompileSFCTemplate- Compiles Pug to HTML, then parses it into an AST using@vue/compiler-dom
- Uses
pug-lexerto convert Pug syntax into tokens - Uses
pug-parserto parse tokens into an AST - Traverses the AST to generate HTML while building a source map
- Uses
@vue/compiler-dom.parseto parse the HTML - Uses
@vue/compiler-dom.transformto transform the AST - Maps error and warning positions back to the original Pug code via the source map
@vue/language-core- Core module
MIT License
{ "vueCompilerOptions": { "plugins": ["@vue/language-plugin-pug"] } }