Angular docs "Show code" chooses generated template over user-defined template
See original GitHub issueDescribe the bug “Show code” in the Docs tab prioritises showing generated template over a template specified using the “template” property
To Reproduce Steps to reproduce the behavior:
Create a story with a template
export const MySelector: Story = (args) => ({
props: {
label: foo
},
template: '<my-selector randomattribute [label]="label"></my-selector>'
});
Go to Docs and click Show code. The randomattribute will not be visible.
Expected behavior My thinking is that anything defined by a user should be prioritised over a generated template as the user may want to include additional code in the template.
Also, if a component has multiple selectors, the generated template chooses the first selector (if this PR is accepted - #14230) whereas a template may specify a second or n selector which we would want to show in “Show code”
“Show code” should always show the user-defined template code when available
Code snippets
The sourceDecorator function in addons > frameworks > angular has this line. If the template and source are swapped then it fixes this
channel.emit(SNIPPET_RENDERED, context.id, prettyUp(source || template));
System Using a fork of 6.2@beta14
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:21 (19 by maintainers)

Top Related StackOverflow Question
@stefan-schweiger there are other frameworks that also support a template, so it’s not an outrageous idea. can you paste an example of a story using a template, some arg values, and the resulting string you’d like to show? 🙏
@shilman I’ve tried to make a repro, but yes there seems to be something up with my setup. But just showing the story source is only marginally more useful, because this was always an option with the storysource addon.
Is there anything in particular blocking us from implementing an additional option to just render out the template string with the args and showing it? I would be fine if this would not be the default behaviour but I think for more complex components this would be a useful feature.