Clone this wiki locally
This is a small plug-in to provide an easy way to display a diff of two “files”
(long strings…) as html. It uses the diff-lcs gem to calculate the diff.
The default output “generator” creates table-rows in the following scheme:
It applies different css classes to the elements depending on match/difference.
This plug-in relies on the diff-lcs gem.
install it as any other plug-in and be sure to include the provided sample css or
your own css rules to the applications-stylesheet.
in your view simply call:
<%= diff(@difftest.old, @difftest.new) %>
which results in:
<tr><td>1. </td><td><pre class="only_a">require 'digest/sha1'</pre></td><td><pre class="only_b">require 'digest/sha2'</pre></td><td>1. </td></tr>
2. 2. 3. class User < ActiveRecord::Base 3.
Copyright © 2008 [Johannes / firstname.lastname@example.org], released under the MIT license