--- /dev/null
+{% autoescape 'js' %}
+(function (xpath) {
+ function getElement(xpath, within) {
+ var result;
+ if (within === null || within === undefined) {
+ within = document;
+ }
+ result = document.evaluate(xpath, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+ if (result.snapshotLength !== 1) {
+ return null;
+ }
+ return result.snapshotItem(0);
+ }
+
+ var node = getElement(xpath);
+
+ if (node === null) {
+ return null;
+ }
+
+ if(node.tagName.toLowerCase() != "input"){
+ return null;
+ }
+
+ if(node.type.toLowerCase() != "checkbox" && node.type.toLowerCase() != "radio"){
+ return null;
+ }
+
+ return node.checked;
+}('{{ xpath }}'));
+{% endautoescape %}