In android mobile browser, compiling a dust.js template caused the error "p.substr [undefined]". It worked fine in desktop browsers. The reason for the error was the closing of <input class="xyz" /> tag elements. Same in the case of img tag as well. So writing the element like