CHANGELOG.md in nice_partials-0.9.3 vs CHANGELOG.md in nice_partials-0.10.0
- old
+ new
@@ -1,6 +1,68 @@
## CHANGELOG
+* Feature: partial's expose `local_assigns` + `locals` alias
+
+ ```html+erb
+ <%# app/views/articles/show.html.erb %>
+ <%= render "section", id: "an_article" %>
+
+ <%# app/views/application/_section.html.erb %>
+ <%# We can access the passed `id:` like this: %>
+ <% partial.local_assigns[:id] %>
+ <% partial.locals[:id] %>
+ ```
+
+ Note: this is equal to the default partial local variable of `local_assigns`, but it becomes more useful with the next feature below.
+
+* Feature: partial helpers can access `partial`
+
+ ```html+erb
+ <%# app/views/articles/show.html.erb %>
+ <% render "section", id: "an_article" do |section| %>
+ <%= tag.h1 "An Article", id: section.labelledby %>
+ <% end %>
+
+ <%# app/views/application/_section.html.erb %>
+ <%
+ partial.helpers do
+ def aria
+ partial.locals.fetch(:aria, {}).with_defaults(labelledby:)
+ end
+
+ def labelledby
+ id = partial.locals[:id] and "#{id}_label"
+ end
+ end
+ %>
+
+ <%= tag.section partial.yield, id:, aria: partial.aria %>
+ ```
+
+### 0.9.4
+
+* Feature: declare contents via `required` and `optional`
+
+ ```html+erb
+ <% if partial.title? %>
+ <h1 class="text-xl">
+ <%= partial.title %>
+ </h1>
+ <% end %>
+
+ <div><%= partial.body %></div>
+ ```
+
+ Can now become:
+
+ ```html+erb
+ <%= partial.title.optional.h1 class: "text-xl" %><%# Will not output any HTML element if no content has been provided. %>
+
+ <div><%= partial.body.required %></div> <%# Raises when this line is hit if no content has been provided %>
+ ```
+
+ See the README for more.
+
### 0.9.3
* Fixed: section predicates not respecting `local_assigns` content
Previously, when doing something like this: