-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use element name local in generators (#1556)
* Use element name as local variable in element generator * Generate nested elements in a fast way By using the render collection short cut Rails uses template caching to speed up rendering the nested elements collection.
- Loading branch information
Showing
18 changed files
with
44 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
spec/dummy/app/views/alchemy/elements/_all_you_can_eat_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(bild_view) do -%> | ||
<%= element_view_for(bild_view) do |el| -%> | ||
<%= el.render :image %> | ||
<%- end -%> | ||
<%- end -%> |
4 changes: 2 additions & 2 deletions
4
spec/dummy/app/views/alchemy/elements/_contactform_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
spec/dummy/app/views/alchemy/elements/_download_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(download_view) do -%> | ||
<%= element_view_for(download_view) do |el| -%> | ||
<%= el.render :file %> | ||
<%- end -%> | ||
<%- end -%> |
4 changes: 2 additions & 2 deletions
4
spec/dummy/app/views/alchemy/elements/_erb_element_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(erb_element_view) do -%> | ||
<%= element_view_for(erb_element_view) do |el| -%> | ||
<%= el.render :text %> | ||
<%- end -%> | ||
<%- end -%> |
4 changes: 2 additions & 2 deletions
4
spec/dummy/app/views/alchemy/elements/_gallery_picture_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element, class: 'gallery_image') do |el| -%> | ||
<%- cache(gallery_picture_view) do -%> | ||
<%= element_view_for(gallery_picture_view) do |el| -%> | ||
<%= el.render :picture, size: '160x120' %> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(gallery_view) do -%> | ||
<%= element_view_for(gallery_view) do |el| -%> | ||
<div class="gallery_images"> | ||
<%- element.nested_elements.available.each do |nested_element| -%> | ||
<%= render_element(nested_element) %> | ||
<%- end -%> | ||
<%= render gallery_view.nested_elements.available %> | ||
</div> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(header_view) do -%> | ||
<%= element_view_for(header_view) do |el| -%> | ||
<%= el.render :image %> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<h1 id="<%= element_dom_id(element) %>" <%= element_preview_code(element) -%>><%= render_essence_view_by_name(element, 'headline') %></h1> | ||
<%= element_view_for(headline_view, tag: 'h1') do |el| %> | ||
<%= el.render(:headline) %> | ||
<% end %> |
8 changes: 3 additions & 5 deletions
8
spec/dummy/app/views/alchemy/elements/_left_column_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<% element.nested_elements.available.each do |nested_element| %> | ||
<%= render_element(nested_element) %> | ||
<% end %> | ||
<%- cache(left_column_view) do -%> | ||
<%= element_view_for(left_column_view) do |el| -%> | ||
<%= render left_column_view.nested_elements.available %> | ||
<%- end -%> | ||
<%- end -%> |
9 changes: 4 additions & 5 deletions
9
spec/dummy/app/views/alchemy/elements/_right_column_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<% element.nested_elements.available.each do |nested_element| %> | ||
<%= render_element(nested_element) %> | ||
<% end %> | ||
<%- cache(right_column_view) do -%> | ||
<%= element_view_for(right_column_view) do |el| -%> | ||
<%= el.render :title %> | ||
<%= render right_column_view.nested_elements.available %> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(search_view) do -%> | ||
<%= element_view_for(search_view) do |el| -%> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%= render element.nested_elements %> | ||
<%- cache(slider_view) do -%> | ||
<%= element_view_for(slider_view) do |el| -%> | ||
<%= render slider_view.nested_elements.available %> | ||
<%- end -%> | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<%- cache(element) do -%> | ||
<%= element_view_for(element) do |el| -%> | ||
<%- cache(text_view) do -%> | ||
<%= element_view_for(text_view) do |el| -%> | ||
<%= el.render :text %> | ||
<%- end -%> | ||
<%- end -%> |