/vcerb-proto

A better syntax for rendering View Components

Primary LanguageRuby

VCERB prototype

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.

What is VCERB?

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} />

Running the example

Bundle, rails server, open localhost:3000.

Notable files in the example