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

feat: Add a method to render a component to string #561

Open
jaredcwhite opened this issue May 22, 2022 · 3 comments
Open

feat: Add a method to render a component to string #561

jaredcwhite opened this issue May 22, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@jaredcwhite
Copy link
Member

jaredcwhite commented May 22, 2022

Summary

The ability to render a component in any codepath, not just in views.

Something like:

output = Shared::Navbar.new(resource:).render_to_string
puts output

Unresolved Questions

How best to "boot up" a skeleton view context from which a component render can occur…any problematic edge cases? Performance issues? * Note: this is already done from dynamic Roda routes…just need to extract/generalize maybe…

@jaredcwhite jaredcwhite added the enhancement New feature or request label May 22, 2022
@andrewmcodes
Copy link
Contributor

I'll be watching closely.

A usecase that comes to mind immediately is using this with something like Storybook, specifically @storybook/html.

Not precise code but I think a primitive example would look like:

storiesOf('Callout', module)
  .add('default', () => '<%= Callout.new(type: :alert, message: "A test callout").render_to_string %>')

And then you can just let Bridgetown convert the ERB. which will build your stories when your components change 👏

@jaredcwhite
Copy link
Member Author

@andrewmcodes That's a pretty neat idea!

@jaredcwhite jaredcwhite added this to the 1.2 milestone Jul 18, 2022
@jaredcwhite jaredcwhite removed this from the 1.2 milestone Sep 23, 2022
@jaredcwhite
Copy link
Member Author

(Pushing this off the 1.2 release…there's a bit of a larger refactor I'd like to do around template/component rendering and I want to give that my full attention rather than rush it.)

@jaredcwhite jaredcwhite added this to the 2.0 milestone Apr 5, 2023
@jaredcwhite jaredcwhite removed this from the 2.0 milestone Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants