Back to Skills

vanilla-rails-views

verified

Use when writing ERB templates, partials, view helpers, or Turbo Stream responses - covers partial organization, optional locals, CSS class patterns, collection rendering

View on GitHub

Marketplace

zemptime-marketplace

ZempTime/zemptime-marketplace

Plugin

vanilla-rails

Repository

ZempTime/zemptime-marketplace
1stars

vanilla-rails/skills/views/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/ZempTime/zemptime-marketplace/blob/main/vanilla-rails/skills/views/SKILL.md -a claude-code --skill vanilla-rails-views

Installation paths:

Claude
.claude/skills/vanilla-rails-views/
Powered by add-skill CLI

Instructions

# Views & Templates

ERB conventions for vanilla Rails applications.

## Partial Organization

**Lowest common ancestor** - place partials at the highest shared directory:

```
# Shared by cards/show and cards/index
app/views/cards/_card.html.erb

# Shared across controllers
app/views/application/_flash.html.erb

# Display variants of same model
app/views/cards/display/_compact.html.erb
app/views/cards/display/_full.html.erb
```

**Never** create deeply nested partials only used in one place.

## Optional Locals

Use `local_assigns.fetch` with explicit defaults:

```erb
<%# Good - explicit default, raises if required %>
<% pinned = local_assigns.fetch(:pinned, false) %>
<% card = local_assigns.fetch(:card) %>

<%# Bad - silent nil, ambiguous intent %>
<% pinned = local_assigns[:pinned] || false %>
```

## CSS Class Helper

Build classes with array + compact + join:

```erb
<%# Good %>
<div class="<%= [
  'card',
  ('card--pinned' if card.pinned?),
  ('card--closed' if card.closed?)
].compact.join(' ') %>">

<%# Bad - string interpolation %>
<div class="card <%= 'card--pinned' if card.pinned? %>">
```

For complex cases, use `token_list` helper:

```erb
<div class="<%= token_list('card', 'card--pinned': card.pinned?) %>">
```

## Collection Rendering

Always cache, always specify `as:`:

```erb
<%= render partial: 'cards/card',
           collection: @cards,
           as: :card,
           cached: true %>
```

## Turbo Streams

Prepend/append with update for empty states:

```erb
<%# Add item and update counter/empty state %>
<%= turbo_stream.before :cards, @card %>
<%= turbo_stream.update :cards_count, @cards.count %>

<%# Remove and handle empty %>
<%= turbo_stream.remove @card %>
<%= turbo_stream.update :cards_empty, partial: 'empty' if @cards.none? %>
```

## Stimulus Integration

Layer controllers on existing elements:

```erb
<%# Good - multiple controllers on body %>
<body data-controller="keyboard shortcuts dropdown">

<%# Bad - wrapper div just for controll

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
2789 chars

Issues Found:

  • name_directory_mismatch