You can use JavaScript Use API,, assume this code is present in file name first.js"use strict"; use(function () { eurl = encodeURI(this.url); return eurl; });and call this via <sly data-sly-use.info="${'first.js' @ url=properties.jcr:title}"> <h1> ${info} </h1> </sly>