# Turning violation nodes into readable HTML The violations returns a list of rules that had failures. Each rule has a list of nodes that failed the rule. Each node may have failed for one or more reasons. This information is encoded in a set of structures that can be somewhat difficult to comprehend. This code shows how to turn a list of violations into a table and then for each node in a rule's nodes list, how to generate a summary of the reason(s) that rule failed. The example uses handlebars templates but can be easily adapted to other formats ## The JavaScript ```js function helperItemIterator(items, template) { var out = ''; if (items) { for (var i = 0; i < items.length; i++) { out += template(items[i]); } } return out; } Handlebars.registerHelper('violations', function(items) { return helperItemIterator(items, compiledRowTemplate); }); Handlebars.registerHelper('related', function(items) { return helperItemIterator(items, compiledRelatedNodeTemplate); }); Handlebars.registerHelper('reasons', function(items) { return helperItemIterator(items, compiledFailureTemplate); }); // Setup handlebars templates compiledRowTemplate = Handlebars.compile(rowTemplate.innerHTML); compiledTableTemplate = Handlebars.compile(tableTemplate.innerHTML); compiledRelatedListTemplate = Handlebars.compile(relatedListTemplate.innerHTML); compiledRelatedNodeTemplate = Handlebars.compile(relatedNodeTemplate.innerHTML); compiledFailureTemplate = Handlebars.compile(failureTemplate.innerHTML); compiledReasonsTemplate = Handlebars.compile(reasonsTemplate.innerHTML); function messageFromRelatedNodes(relatedNodes) { var retVal = ''; if (relatedNodes.length) { var list = relatedNodes.map(function(node) { return { targetArrayString: JSON.stringify(node.target), targetString: node.target.join(' ') }; }); retVal += compiledRelatedListTemplate({ relatedNodeList: list }); } return retVal; } function messagesFromArray(nodes) { var list = nodes.map(function(failure) { return { message: failure.message.replace(//gi, '>'), relatedNodesMessage: messageFromRelatedNodes(failure.relatedNodes) }; }); return compiledReasonsTemplate({ reasonsList: list }); } function summary(node) { var retVal = ''; if (node.any.length) { retVal += '