Commit bafb0c49 by Jan Hrabal

templates

parent ca44afd2
......@@ -33,7 +33,9 @@ public class HibernateLoaderTemplateService implements TemplateService {
if (valuesConfig != null) {
values.putAll(valuesConfig.getValues());
}
if (data != null) {
values.putAll(data);
}
String content = t.getTemplate();
StringWriter sw = new StringWriter();
......
......@@ -4,6 +4,7 @@ import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
public class HibernateTemplateLoader implements TemplateLoader {
......@@ -14,12 +15,15 @@ public class HibernateTemplateLoader implements TemplateLoader {
@Override
@Transactional
public Template loadTemplate(String code, Locale locale) {
String l = locale == null ? null : (locale.getLanguage() + "-" + locale.getCountry());
Template t = repository.loadTemplate(code, l);
//TODO refactor
Template t = null;
if (locale != null) {
if (StringUtils.hasText(locale.getCountry())) {
t = repository.loadTemplate(code, locale.getLanguage() + "-" + locale.getCountry());
}
if (t == null) {
t = repository.loadTemplate(code, locale.getLanguage());
}
}
if (t == null) {
t = repository.loadTemplate(code, null);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment