Reparse a parse(.vm) file after editing without restarting

Jared Farrish October 11, 2011

I have a .vm template:

#set($padSize = 0)
>$stringUtils.leftPad($i18n.getText("common.concepts.key"), $padSize): ${issue.getKey()}
>$stringUtils.leftPad($i18n.getText("common.concepts.url"), $padSize): ${baseurl}/browse/${issue.getKey()}
>$stringUtils.leftPad($i18n.getText("common.concepts.project"), $padSize): $issue.getProject().name
>$stringUtils.leftPad($i18n.getText("common.concepts.issuetype"), $padSize): $issue.getIssueTypeObject().getNameTranslation($i18n)
#if ($issue.reporterUser)
>$stringUtils.leftPad($i18n.getText("issue.field.reporter"), $padSize): $!issue.reporterUser.fullName
#end
#if ($issue.assigneeUser)
>$stringUtils.leftPad($i18n.getText("issue.field.assignee"), $padSize): $!issue.assigneeUser.fullName
#end
#if ($issue.getPriorityObject() && $issue.getPriorityObject().getId() != $constantsManager.getDefaultPriority().getString("id"))
>$stringUtils.leftPad($i18n.getText("issue.field.priority"), $padSize): $issue.getPriorityObject().getNameTranslation($i18n)
#end
#if ($attachments && $attachments.size() >0)
>$stringUtils.leftPad($i18n.getText("template.attachments"), $padSize): #foreach ($attachment in $attachments)$attachment.getFilename()#if ($velocityCount != $attachments.size()), #end#end
>
#end
>
$!{velocityhelper.quote($!issue.description)}

It is being parsed by another template:

#parse("templates/email/text/includes/issuesummarymin.vm")

It appears to be cached however, and the following settings have no effect for Velocity-parsed templates:

class.resource.loader.cache=false
velocimacro.library.autoreload=true

Is there a way for me to get the .vm file reparsed by Velocity so the template edits appear, without doing a restart?

1 answer

0 votes
StaceyA February 3, 2012

It should reparse the velocity template when you make edits. Does your project run from a target directory? Double check that the file is being copied over correctly to whichever directory you are running the project from. Also, is your browser doing some strange caching? Sometimes I find when I'm redoing the same template a lot my browser caches it and even with a hard page refresh maintains the old copy.

Jared Farrish February 5, 2012

Hi Stacey, thank you for the response. The issue is that Velocity itself is caching files that have been parsed using the #parse() directive within a template. So the main template (that's calling on #parse() for another template, like an include file) is updating (no issues with browser caching here), but it stubbornly refuses to reparse the "included" #parse()ed templates. Does that make sense?

Andreas Gounaris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

Have you tried touching the main template?

Suggest an answer

Log in or Sign up to answer