<% if @linkables_cache %> <%= content_for :javascript do %> var tribute = new Tribute({ <%# TODO: tribute allows us to populate values async, so that might be worth exploring the tradeoffs of https://github.com/zurb/tribute %> values: [ <% @linkables_cache.each do |class_name, collection| %> <% linkable_class = content_class_from_name(class_name) %> <% collection.each do |page_name, page_id| %> { key: "<%= page_name.gsub('"', "\"").gsub("\n", " ").gsub("\r", " ").strip %>", value: '[[<%= class_name %>-<%= page_id %>]]', color: '<%= linkable_class.color %>', icon: '<%= linkable_class.icon %>' }, <% end %> <% end %> ], selectTemplate: function (item) { // We're overriding the default here so we don't prepend a @ return item.original.value; }, menuItemTemplate: function (item) { return '' + item.original.icon + '' + item.string; }, spaceSelectsMatch: false }); tribute.attach(document.querySelectorAll('.js-can-mention-pages')); <% end %> <% end %>