nghtml2pug
Converts angular HTML to Pug templating language (formerly Jade).
Initially forked from html2pug
Turns this 😒
{{ i + 1}}.{{ item }}
Into this 🎉
ng-container(*ngFor='lel item of items; let i = index') span.icon | {{ i + 1}}.{{ item }}
IMPORTANT: PEER DEPENDENCY
It uses Angular HTML parser from "@angular/compiler": "^7.2.15"
.
So there is a peer dependency, make sure you have it installed.
Install
Get it on npm:
npm i nghtml2pug
In case your project doesn't have @angular/compiler
npm i @angular/compiler
Usage
CLI using NPX
Accept input from a file or stdin and write to stdout:
# choose a file npx nghtml2pug < example.html # use pipe echo '<h1>foo</h1>' | npx nghtml2pug
Write output to a file:
npx nghtml2pug < example.html > example.pug
npx nghtml2pug -- --help
for more information.
Programmatically
const ngHTML2Pug = const html = '<tg-template #title><h1>Hello World!</h1></ng-template>'const pug =
Options
Name | Type | Default | Description |
---|---|---|---|
useTabs | Boolean | false |
Use tabs instead of spaces |
useDoubleQuotes | Boolean | false |
Use double quotes instead of single quotes |