This project explores a way to conveniently render View Components using Va custom ActionView template handler.
When successful, this will be rewritten as a gem to include in a Rails app.
VCERB syntax allows developers to instiate View Components using HTML tags, not unlike React or Blazor.
Example:
<!-- VCERB syntax -->
<Notification title="my title">
Hello, world
</Notification>
<!-- Standard ViewComponent syntax -->
<%= render(NotificationComponent.new(title: "my title")) do %>
Hello, World!
<% end %>
To include literal Ruby in params:
<Notification title={@title.upcase} />
Bundle, rails server, open localhost:3000.
- app/views/page/index.html.vcerb a demo vcerb view
- lib/vcerb.rb the template handler
- config/initializers/vcerb.rb an initializer that registers the template handler