Skip to content

initial support for support jade/pug templates #4109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
npm uninstall -g ng-cli
npm i -g https://github.com/tycho01/angular-cli.git#pug-html

## Angular-CLI

[![Join the chat at https://gitter.im/angular/angular-cli](https://badges.gitter.im/angular/angular-cli.svg)](https://gitter.im/angular/angular-cli?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down Expand Up @@ -315,6 +318,15 @@ You use the `assets` array in `angular-cli.json` to list files or folders you wa
]
```

### Template engines

Template engines currently supported are HTML and [Pug](https://pugjs.org/) (née Jade).
Template engines other than HTML require processing through webpack, so should be
included from their own file using `templateUrl`, whereas HTML supports using
`@Component`'s `template` property as well. Example:
- before: `@Component({ template: '<p>Hello world</p>' })` or `@Component({ templateUrl: './foo.html' })`
- after: `@Component({ templateUrl: './foo.pug' })`

### Global styles

The `styles.css` file allows users to add global styles and supports
Expand Down
9 changes: 9 additions & 0 deletions docs/documentation/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ ng e2e
Before running the tests make sure you are serving the app via `ng serve`.
End-to-end tests are run via [Protractor](https://angular.github.io/protractor/).

### Template engines

Template engines currently supported are HTML and [Pug](https://pugjs.org/) (née Jade).
Template engines other than HTML require processing through webpack, so should be
included from their own file using `templateUrl`, whereas HTML supports using
`@Component`'s `template` property as well. Example:
- before: `@Component({ template: '<p>Hello world</p>' })` or `@Component({ templateUrl: './foo.html' })`
- after: `@Component({ templateUrl: './foo.pug' })`

### Global styles

The `styles.css` file allows users to add global styles and supports
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@angular/compiler-cli": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/tsc-wrapped": "^0.5.0",
"apply-loader": "^0.1.0",
"async": "^2.1.4",
"autoprefixer": "^6.5.3",
"chalk": "^1.1.3",
Expand Down Expand Up @@ -88,6 +89,9 @@
"portfinder": "1.0.9",
"postcss-discard-comments": "^2.0.4",
"postcss-loader": "^0.9.1",
"protractor": "^3.3.0",
"pug": "^2.0.0-beta6",
"pug-loader": "^2.3.0",
"quick-temp": "0.1.5",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.8",
Expand Down
5 changes: 4 additions & 1 deletion packages/angular-cli/models/webpack-build-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ export function getWebpackCommonConfig(
loader: `url-loader?name=[name]${hashFormat.file}.[ext]&limit=10000`
},
{ test: /\.html$/, loader: 'raw-loader' },

 {
 test: /\.(pug|jade)$/,
 loaders: ['apply-loader', 'pug-loader'],
 },
{
test: /\.(otf|ttf|woff|woff2)$/,
loader: `url-loader?name=[name]${hashFormat.file}.[ext]&limit=10000`
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
div
h1 hello world
a('[routerLink]'="['lazy']") lazy
router-outlet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Component, ViewEncapsulation} from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
templateUrl: './app.component.pug',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None
})
Expand Down
16 changes: 16 additions & 0 deletions tests/e2e/tests/build/templates/html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {
writeMultipleFiles,
expectFileToMatch,
} from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { stripIndents } from 'common-tags';

export default function () {
return writeMultipleFiles({
'src/app/app.component.html': stripIndents`
<h1>foo</h1>
`})
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/app/app.component.html',
/<h1>foo<\/h1>/))
}
21 changes: 21 additions & 0 deletions tests/e2e/tests/build/templates/pug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
writeMultipleFiles,
deleteFile,
expectFileToMatch,
replaceInFile
} from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { stripIndents } from 'common-tags';

export default function () {
return writeMultipleFiles({
'src/app/app.component.pug': stripIndents`
h1 foo
`})
.then(() => deleteFile('src/app/app.component.html'))
.then(() => replaceInFile('src/app/app.component.ts',
'./app.component.html', './app.component.pug'))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/app/app.component.pug', // .html?
/<h1>foo<\/h1>/))
}