<% if UxToolkitTextSnippet.table_available? %>
  <% snippets = UxToolkitTextSnippet.enabled.ordered.to_a %>

  <% if snippets.any? %>
    <div class="ux-toolkit-text-snippet-insert"
         data-empty-snippet-message="<%= h(l(:text_ux_toolkit_select_text_snippet_first)) %>">
      <p>
        <label for="ux_toolkit_text_snippet_select"><%= l(:label_ux_toolkit_text_snippet) %></label>
        <%= select_tag 'ux_toolkit_text_snippet_select',
                       options_for_select(
                         [[l(:label_ux_toolkit_no_text_snippet), '', {'data-snippet-text' => ''}]] +
                           snippets.map do |snippet|
                             [
                               snippet.title,
                               snippet.id,
                               {'data-snippet-text' => snippet.snippet_text.to_s}
                             ]
                           end
                       ),
                       id: 'ux_toolkit_text_snippet_select' %>
        <button type="button"
                class="button-small ux-toolkit-text-snippet-insert-button">
          <%= l(:button_ux_toolkit_insert_text_snippet) %>
        </button>
      </p>
      <em class="info"><%= l(:text_ux_toolkit_text_snippet_insert_help) %></em>
    </div>
  <% end %>
<% end %>
