Skip to content

Commit

Permalink
GRAILS-12007 search for templates in parents of parents too
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Mar 3, 2015
1 parent 947a1bc commit eb53e69
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,28 @@ class RenderStep extends AbstractStep {
}
}


protected void renderToDestination(File destination, Map variables) {
Profile profile = command.profile
protected File searchTemplateDepthFirst(Profile profile, String template) {
File profileDir = profile.profileDir
File templateFile = new File(profileDir, parameters.template)
if(!templateFile.exists()) {
File templateFile = new File(profileDir, template)
if(templateFile.exists()) {
return templateFile
} else {
for(parent in profile.extends) {
templateFile = new File(parent.profileDir, parameters.template)
if(templateFile.exists()) break
templateFile = searchTemplateDepthFirst(parent, template)
if(templateFile) {
return templateFile
}
}
}
null
}

protected void renderToDestination(File destination, Map variables) {
Profile profile = command.profile
File templateFile = searchTemplateDepthFirst(profile, parameters.template)
if(!templateFile) {
throw new IOException("cannot find template " + parameters.template)
}
destination.text = new SimpleTemplate(templateFile.text).render(variables)
ClassNameCompleter.refreshAll()
}
Expand Down

0 comments on commit eb53e69

Please sign in to comment.