question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular docs "Show code" chooses generated template over user-defined template

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:21 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Aug 2, 2021

@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? 🙏

1reaction
stefan-schweigercommented, Jul 28, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating code using schematics - Angular
A schematic is a template-based code generator that supports complex logic. ... CLI for each of the ng generate sub-commands, as shown in...
Read more >
Using Templates - OpenAPI Generator
OpenAPI Generator applies user-defined templates via options: ... Next, we'll find the code which generates API methods.
Read more >
How To Use Custom Form Validation in Angular - DigitalOcean
Learn how to create a custom validator in Angular for both template-driven and reactive forms.
Read more >
Snippets in Visual Studio Code
Single-language user-defined snippets are defined in a specific language's snippet file (for example javascript.json ), which you can access by language ...
Read more >
Coding Assistance in C++ | ReSharper Documentation
For example, when you call a member function declaration on the object. ... ReSharper C++: code completion in dependent code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found