Sha256: 8548d91d093380ebac86461a8244c9e19a9610ab2cdf07c89d3ba5f919858528
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
<% # headmin/forms/blocks # # ==== Options # * <tt>form</tt> - Form object # * <tt>path</tt> - Directory where to look for block templates # * <tt>allow</tt> - Names of block templates that can be added # # ==== Examples # Basic version. This will only look for blocks in 'admin/blocks' # <%= render "headmin/forms/blocks", form: form %#> # # Define the path to look for block templates like this: # <%= render "headmin/forms/blocks", form: form, path: 'admin/pages/blocks' %#> # # Limit the types of blocks # <%= render "headmin/forms/blocks", form: form, allow: ['text', 'text-image'] %#> path = local_assigns.has_key?(:path) ? path : nil allowed_block_names = local_assigns.has_key?(:allow) ? allow.map(&:to_s) : BlockService.block_names(path: path) templates = allowed_block_names.map { |name| BlockService.form_view(name, path: path) } %> <%= render 'headmin/forms/repeater', form: form, attribute: :blocks, templates: templates, label: false do |block| %> <% view_path = BlockService.form_view(block.object.name, path: path).gsub('/_', '/') %> <%= render view_path, form: block, name: block.object.name %> <span class="position-absolute top-0 end-0 badge bg-light text-dark"> <%= block.object.name.titleize %> </span> <% end %>
Version data entries
6 entries across 6 versions & 1 rubygems