Currently, I am utilizing prismjs
to add syntax highlighting to my Rails application. The stylesheet and js file have been included in my layout, however, an issue arises where the code is only highlighted once during the initial page load. Subsequently, after an ajax call triggers a partial refresh, the code highlighting ceases to function. Interestingly, if I include the prismjs file within the partial itself, the highlighting works as expected. Are there any alternative methods to ensure consistent functionality without having to include the file in each partial?
layout.html.erb
<%= stylesheet_link_tag :prism %>
<%= javascript_include_tag :prism %>
The above code successfully highlights the syntax on the initial page load. However, for subsequent ajax calls, it becomes necessary to include the following:
partial.html.erb
<%= javascript_include_tag :prism %>
Are there any alternative solutions to achieve the same result, such as calling the file through a custom event or utilizing another method?