Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render snippets as component #75

Open
Wolfr opened this issue Jun 9, 2020 · 1 comment
Open

Render snippets as component #75

Wolfr opened this issue Jun 9, 2020 · 1 comment

Comments

@Wolfr
Copy link

Wolfr commented Jun 9, 2020

I have a question about this package.

Is it possible to also render out the snippets as the component itself instead of code? This way I can then use the same file for the "displaying" of the component as the snippet itself.

I have style guides that look like this:

image

This Panel is then placed under /snippets/panel-with-double-body.hbs. That file contains code like this:

  <Panel as |pl|>
    <pl.Header>
      <h4 class="c-panel__title">Panel header</h4>
    </pl.Header>
    <pl.Body>
      <p>Lorem ipsum dolor sit amet.... </p>
    </pl.Body>
    <pl.Body>
      <p>Lorem ipsum dolor sit amet.... </p>
    </pl.Body>
  </Panel>

I am using this package and ember codeblock to render the code:

{{#let (get-code-snippet @snippet) as |snippet|}}
  <CodeBlock
    class="br-styleguide-code-block"
    @code={{snippet.source}}
    @language="markup"
  />
{{/let}}

Now, can I also use this file to render out the visual example?

@ef4
Copy link
Owner

ef4 commented Jun 10, 2020

I think the easiest way to do this is not to use a standalone "snippets" folder, but instead to use BEGIN-SNIPPET comments as described in the README.

This way, you would place all your examples somewhere under app/components so that you'd be able to render them normally, but you could also have snippet comments inside each one so you could get their source code to show alongside their renderer form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants