It's not possible to call set on both paths for every change without creating a loop. This is by definition, a loop.
One solution would be to disable the on('value', ...) events while the user is typing into the field. Another solution would be to only call set from tmpltr.editors after the user leaves the field, or after a save button is clicked (instead of for each change).
var isTyping = false;
tmpltr.editors.data.getSession().on('focus', function() {
isTyping = true;
});
tmpltr.editors.data.getSession().on('blur', function() {
isTyping = false;
});
collabjs.on('value', function(snap) {
if( !isTyping ) {
tmpltr.fn.setData(snapshot.val());
tmpltr.fn.renderOutput("html");
tmpltr.editors.data.session.setValue(snapshot.val());
}
});
/* and so on... */
If you are attempting to create a collaborative editor where multiple users can type simultaneously, check out FirePad for an example, which is a drop-in Firebase tool for collaborative editing.