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 :inline output is empty and requires a preview partial #656

Open
caged opened this issue Dec 4, 2024 · 0 comments
Open

render :inline output is empty and requires a preview partial #656

caged opened this issue Dec 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@caged
Copy link

caged commented Dec 4, 2024

Describe the bug

👋 Thanks for the work you've done here! I have several "components" that are essentially a CSS class and some plain HTML. When you render these inline, you encounter a couple of issues. The first is that Lookbook wants a "preview" view to exist in app/views/lookbook/previews/_preview.html.erb and the second issue is that render inline: "foo" doesn't output anyting.

To Reproduce

  1. Create a preview and use render inline: to render a bit of ERB or plain HTML.
class ButtonPreview < Lookbook::Preview
  def primary
    render inline: `<button class="btn-primary">Test</button>`
  end
end
  1. Open the preview in your browser and note the error needing a _preview.html.erb partial.
  2. Add an empty _preview.html.erb partial in the location requested as a workaround.
  3. Refresh the preview in the browser and note that there is no button shown.

Expected behavior

A button preview will render and there will be no requirement of a separate _preview partial.

Screenshots

If applicable, add screenshots to help explain your problem.

Version numbers

Please complete the following information:

  • Lookbook: 2.3.4
  • ViewComponent: n/a
  • Rails: 8.0.0
  • Ruby: 3.3.6
@caged caged added the bug Something isn't working label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant