Replies: 1 comment 2 replies
-
See: https://storybook.js.org/docs/api/csf#custom-render-functions My personal understanding: In cases where you need to provide a render template (if its just your components args - see "CSF 3 - default render function" you do not need to set the render template string) - you can use the argsToTemplate Function to spread the args that you've set in the story or the (meta.args!) to the components string template. You could also use the options to include or exclude some args. It's very convenient when you need to have the string template, but don't want to set all inputs and outputs manually all the time. Example from the Documentation:
With a subset of args - only conceptual example i just drafted, there are other or maybe better ways to spread args, its just to show argsToTemplate in the template string:
So now, with args to template, storybook can populate your components args in a pretty way to the "show code" section and to the controls addon. And you save yourself some manual work. But as the documentation mentioned, the best way is to try to not use custom templates when the render function is unneccessary to convert your args to the components default template. -> https://storybook.js.org/docs/api/csf#default-render-functions (I hope what I've just explained is okay, please correct me or show more examples (maybe how to spread other stories args?), storybooks documentation + angular is so confusing sometimes, so that sometimes I'm just guessing with try + error (: ) |
Beta Was this translation helpful? Give feedback.
-
Summary
So on this page there is a reference and a single sentence describing argsToTemplate
https://storybook.js.org/tutorials/intro-to-storybook/angular/en/simple-component/
But there is no mention anywhere else how it works and how it is better than manually placing variables. It just says it makes event binding far easier but doesn't describe what you need to do, it's just in the example.
I don't know if this is the best place to ask, but some additional documentation on argsToTemplate would be greatly appreciated.
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions