feat(aio): display “code sample missing” message when no code sample
Not having code in a `<code-example>` or `<code-tabs>` is presumed to be an error. Hides the copy button as well.
This commit is contained in:
committed by
Pete Bacon Darwin
parent
ae70293df3
commit
309bae0a0b
@@ -25,7 +25,7 @@ const copiedLabel = 'Copied!';
|
||||
template: `
|
||||
|
||||
<pre class="prettyprint lang-{{language}}">
|
||||
<button class="material-icons copy-button" (click)="doCopy()">content_copy</button>
|
||||
<button *ngIf="code" class="material-icons copy-button" (click)="doCopy()">content_copy</button>
|
||||
<code class="animated fadeIn" #codeContainer></code>
|
||||
</pre>
|
||||
`
|
||||
@@ -70,9 +70,12 @@ export class CodeComponent implements OnChanges {
|
||||
private logger: Logger) {}
|
||||
|
||||
ngOnChanges() {
|
||||
if (!this.code) { return; }
|
||||
this.code = this.code && this.code.trim();
|
||||
|
||||
this.code = this.code.trim();
|
||||
if (!this.code) {
|
||||
this.setCodeHtml('<p class="code-missing">The code sample is missing.</p>');
|
||||
return;
|
||||
}
|
||||
|
||||
const linenums = this.getLinenums();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user