velocitydotcms

how to convert velocity variable to String?


I am using dotCMS server to generate templates based on specified URL using velocity as shown in below.

#foreach($Innowid in $dotcontent.pull("+structureName:Innowid +(conhost:a2f01224-2885-40fd-bde4-a60ae02e3a12 conhost:SYSTEM_HOST)",10,"Innowid.vizlink"))
#editContentlet($Innowid.inode)
<div id="viz" class="visuals"></div>
<script type="text/javascript">
    var url=$!{Innowid.vizlink};
</script>
#end

While iterating "url" value is changing.But it is assigning like var url=https://www.google.co.in/?gfe_rd=cr&ei=fVNMVdahH8GS8QfyqoGQDw&gws_rd=ssl

Now I want to convert the url into a string.


Solution

  • Wrap the variable in quotes or apostrophes.

    var url="$!{Innowid.vizlink}";
    

    You are generating plain Javascript code after all.