jquery - Using Apache Velocity (with SparkJava) with loaded templates -




i building website using spark + velocity. has html components similar across webpages of site, have put shared components in templates dynamically load page.

to give simple example, have pages such this:

anypage.vm

<head> stuff in here </head> <body> <div id="header"></div> $ajavaobject.tostring() # <-- using velocity templating language ... </body> <script type="text/javascript">     $(function(){          $("#header").load("header.vm");     } </script> 

this works right, except fact velocity code inside header.vm won't work.

header.vm

<h1>header</h1> $anotherjavaobject.tostring() 

the header.vm not contain <head> or <body> tagging.

when rendering page, instead of seeing string representation of anotherjavaobject, see actual string $anotherjavaobject.tostring().

any appreciated. thanks.

you can't load in javascript after template return results. should use parse see velocity loading resources:

#parse("header.vm") 

and if need hide use javascript display/hide results.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -