Skip to content

Commit 3a54e92

Browse files
erkamyamanthePunderWoman
authored andcommitted
docs(core): restore the PipeTransform code examples
The PipeTransform usage notes still used AIO `<code-example>` tags, which angular.dev does not render, so the page introduced two `TruncatePipe` examples and then showed nothing. Switch to `{@example}` and give both example files a named region so the extractor can pick them up. (cherry picked from commit 9ba5faa)
1 parent b97cd9a commit 3a54e92

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/core/src/change_detection/pipe_transform.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
*
1616
* In the following example, `TruncatePipe` returns the shortened value with an added ellipses.
1717
*
18-
* <code-example path="core/ts/pipes/simple_truncate.ts" header="simple_truncate.ts"></code-example>
18+
* {@example core/ts/pipes/simple_truncate.ts region='simple-truncate'}
1919
*
2020
* Invoking `{{ 'It was the best of times' | truncate }}` in a template will produce `It was...`.
2121
*
2222
* In the following example, `TruncatePipe` takes parameters that sets the truncated length and the
2323
* string to append with.
2424
*
25-
* <code-example path="core/ts/pipes/truncate.ts" header="truncate.ts"></code-example>
25+
* {@example core/ts/pipes/truncate.ts region='truncate'}
2626
*
2727
* Invoking `{{ 'It was the best of times' | truncate:4:'....' }}` in a template will produce `It
2828
* was the best....`.

‎packages/examples/core/ts/pipes/simple_truncate.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.dev/license
77
*/
8-
// #docregion
8+
// #docregion simple-truncate
99
import {Pipe, PipeTransform} from '@angular/core';
1010

1111
@Pipe({
@@ -16,3 +16,4 @@ export class TruncatePipe implements PipeTransform {
1616
return value.split(' ').slice(0, 2).join(' ') + '...';
1717
}
1818
}
19+
// #enddocregion simple-truncate

‎packages/examples/core/ts/pipes/truncate.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.dev/license
77
*/
8-
// #docregion
8+
// #docregion truncate
99
import {Pipe, PipeTransform} from '@angular/core';
1010

1111
@Pipe({
@@ -16,3 +16,4 @@ export class TruncatePipe implements PipeTransform {
1616
return value.split(' ').slice(0, length).join(' ') + symbol;
1717
}
1818
}
19+
// #enddocregion truncate

0 commit comments

Comments
 (0)