class TemplateBasedApplier implements ChangeScriptApplier {

	public void apply(List<ChangeScript> changeScripts) {
		String filename = syntax + "_" + getTemplateQualifier() + ".ftl";

		try {
			Map<String, Object> model = new HashMap<String, Object>();
			model.put("scripts", changeScripts);
			model.put("changeLogTableName", changeLogTableName);
			model.put("delimiter", delimiter);
			model.put("separator", delimiterType == DelimiterType.row ? "\n" : "");

			try {
				Template template = configuration.getTemplate(filename);
				template.process(model, writer);
			} finally {
				writer.close();
			}
		} catch (FileNotFoundException ex) {
			throw new UsageException("Could not find template named " + filename + "\n" +
					"Check that you have got the name of the database syntax correct.", ex);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public  TemplateBasedApplier(Writer writer, String syntax, String changeLogTableName, String delimiter, DelimiterType delimiterType, File templateDirectory);

}