Move templating logic to Polymer