$ npm install @vue/language-plugin-pug
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-dev
Add this plugin in tsconfig.json:
{
"vueCompilerOptions": {
"plugins": ["@vue/language-plugin-pug"]
}
}
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-dompug-lexer to convert Pug syntax into tokenspug-parser to parse tokens into an AST@vue/compiler-dom.parse to parse the HTML@vue/compiler-dom.transform to transform the AST@vue/language-core - Core moduleMIT License
© 2010 - cnpmjs.org x YWFE | Home | YWFE