Posted by rah003
on January 22, 2013 at 12:15 AM PST
In my last blog post, I explained how to add versioning capability to templates. Being able to create, view and restore different versions of templates is great, but sometimes it's not so easy to see what has actually changed. And we might not be as lucky as having comments about the change from the author, or they might be cryptic to the point of being useless.
The library used here was google-diff-match-patch and as you can see it produces a visual diff of the changed template as well as a patch in unidiff format.
Some extra configuration is also made available for the user to tweak the output of the diff in case the default output is not to their liking. Admittedly I was not very inventive when it came to redefining the description of those options, then again that was not the point of the exercise.
The library is also capable of applying the patch on the source, but this functionality was not explored in the integration.
You can find the code changes necessary for feeding the JS library with two versions of the template in these two tickets: MGNLINTEMPL-26 and MGNLDIFF-25 .