Skip to content

Commit 11f4eb2

Browse files
committed
CrateSidebar: Extract tomlSnippet property
1 parent 113452b commit 11f4eb2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/components/crate-sidebar.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
<p local-class="copy-help">Add the following line to your Cargo.toml file:</p>
2525
{{#if (is-clipboard-supported)}}
2626
<CopyButton
27-
@copyText='{{@crate.name}} = "{{@version.num}}"'
27+
@copyText={{this.tomlSnippet}}
2828
title="Copy Cargo.toml snippet to clipboard"
2929
local-class="copy-button"
3030
>
31-
<span>{{@crate.name}} = "{{@version.num}}"</span>
31+
<span>{{this.tomlSnippet}}</span>
3232
{{svg-jar "copy" aria-hidden="true" local-class="copy-icon"}}
3333
</CopyButton>
3434
{{else}}
3535
<code local-class="copy-fallback">
36-
{{@crate.name}} = "{{@version.num}}"
36+
{{this.tomlSnippet}}
3737
</code>
3838
{{/if}}
3939
</div>

app/components/crate-sidebar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ export default class DownloadGraph extends Component {
2121
}
2222

2323
@gt('sortedVersions.length', NUM_VERSIONS) hasMoreVersions;
24+
25+
get tomlSnippet() {
26+
return `${this.args.crate.name} = "${this.args.version.num}"`;
27+
}
2428
}

0 commit comments

Comments
 (0)