code: public static void generate( Application app, File outputDirectory, Collection<TemplateEntry> templates, Logger logger )
  	throws IOException {
  
  		// Create the context on the fly
  		ApplicationContextBean appCtx = ContextUtils.toContext( app );
  		Context wrappingCtx = Context
  				.newBuilder( appCtx )
  				.resolver(
  					MapValueResolver.INSTANCE,
  					JavaBeanValueResolver.INSTANCE,
  					MethodValueResolver.INSTANCE,
  					new ComponentPathResolver()
  				).build();
  
  		// Deal with the templates
  		try {
  			for( TemplateEntry template : templates ) {
  
  				logger.fine( "Processing template " + template.getTemplateFile() + " to application " + app + "." );
  
  				File target;
  				String targetFilePath = template.getTargetFilePath();
  				if( ! Utils.isEmptyOrWhitespaces( targetFilePath )) {
  					target = new File( targetFilePath.replace( "${app}", app.getName()));
  
  				} else {
  					String filename = template.getTemplateFile().getName().replaceFirst( "\\.tpl$", "" );
  					target = new File( outputDirectory, app.getName() + "/" + filename );
  				}
  
  				Utils.createDirectory( target.getParentFile());
  				String output = template.getTemplate().apply( wrappingCtx );
  				Utils.writeStringInto( output, target );
  
  				logger.fine( "Template " + template.getTemplateFile() + " was processed with application " + app + ". Output is in " + target );
  			}
  
  		} finally {
  			wrappingCtx.destroy();
  		}
  	}
docs: Generates files from templates for a given application.
  <p>
  All the generated files for a given application are located
  under <code>outputDirectory/application-name</code>. Even global templates
  are output there.
  </p>
  
  @param app an application (not null)
  @param outputDirectory the output directory (not null)
  @param templates a non-null collection of templates
  @param logger a logger
  @throws IOException if something went wrong