Has anyone got any experience with using Coderay with html.erb files. I'm unsure how to use coderay with these files.
I have a helper method
def coderay(text)
text.gsub(/\<code( lang="(.+?)")?\>(.+?)\<\/code\>/m) do
CodeRay.scan($3, $2).div(:css => :class)
end
end
I save all my text into my model and encapsulate anything i want formatted using coderay like so
<code lang="ruby">
<div class="sidebarbox-title">
<h3>Posts</h3>
</div>
<% @posts.each do |p| %>
<h3 class="post-header">
<%= p.name %>
</h3>
<% end %>
</code>
when i want to use coderay formatted text in my view i then do
<%= coderay(@post.comments).html_safe %>
How do i specify what the language is though if using .html.erb, so to clarify
<code lang="**What goes here**">
<div class="sidebarbox-title">
<h3>Posts</h3>
</div>
<% @posts.each do |p| %>
<h3 class="post-header">
<%= p.name %>
</h3>
<% end %>
</code>
The docs Here seem to state that it can be done, but cant see how
Thanks
And the answer was stupidly obvious