I am building a website using Spark + Velocity. This has HTML components that are very similar across the webpages of the site, so I have put my shared components in some templates that I dynamically load into the page.
To give you a simple example, I have pages such as this:
anyPage.vm
<head> stuff in here </head>
<body>
<div id="header"></div>
$AJavaObject.ToString() # <-- using the Velocity templating language
...
</body>
<script type="text/javascript">
$(function(){
$("#header").load("header.vm");
}
</script>
This works all right, except for the fact that the Velocity code inside header.vm
won't work.
header.vm
<h1>Header</h1>
$AnotherJavaObject.toString()
The header.vm does not contain any <head>
or <body>
tagging.
When rendering the page, instead of seeing the string representation of the AnotherJavaObject
, I see the actual string $AnotherJavaObject.toString()
.
Any help is appreciated. Thanks.