We can optimize static or partially static Action View Tag Helpers, since the Herb Parser is soon going to understand and transform Action View Tag Helpers to HTML-elements.
Fully Static with dynamic content
For example, for fully static Tag Helpers:
<%= tag.p class: "flex" do %>
<span><%= content %></span>
<% end %>
Currently gets compiled to:
__herb = ::Herb::Engine; _buf = ::String.new;
_buf << __herb.h(tag.p class: "flex" do); _buf << '
<span>'.freeze; _buf << __herb.h((content)); _buf << '</span>
'.freeze; end; _buf << '
'.freeze;
_buf.to_s
Since everything in this Tag-helper call is static, we could optimize it to avoid the helper-related method calls at runtime:
__herb = ::Herb::Engine; _buf = ::String.new;
_buf << '<p class="flex">
<span>'.freeze; _buf << __herb.h((content)); _buf << '</span>
</p>
'.freeze;
_buf.to_s
Fully Static with static content
For fully static tag helper calls with only static content:
<%= tag.p class: "flex" do %>
<span>Content</span>
<% end %>
We can inline everything into a single string:
__herb = ::Herb::Engine; _buf = ::String.new;
_buf << '<p class="flex">
<span>Content</span>
</p>
'.freeze;
_buf.to_s
Partially Static
For partially static Tag Helpers like this:
<%= tag.p class: classes do %>
<span><%= content %></span>
<% end %>
We could optimize it to:
__herb = ::Herb::Engine; _buf = ::String.new;
_buf << '<p class="'.freeze; _buf << ::Herb::Engine.attr((classes)); _buf << '">
<span>'.freeze; _buf << __herb.h((content)); _buf << '</span>
</p>
'.freeze;
_buf.to_s
We can optimize static or partially static Action View Tag Helpers, since the Herb Parser is soon going to understand and transform Action View Tag Helpers to HTML-elements.
Fully Static with dynamic content
For example, for fully static Tag Helpers:
Currently gets compiled to:
Since everything in this Tag-helper call is static, we could optimize it to avoid the helper-related method calls at runtime:
Fully Static with static content
For fully static tag helper calls with only static content:
We can inline everything into a single string:
Partially Static
For partially static Tag Helpers like this:
We could optimize it to: