incl_tmpl.setLoaderContext(context);
// If the included section has modifiers applied, we buffer it into a
// string so that we can apply the modifiers.
PrintWriter previous_printwriter = null;
StringWriter sw = null;
if (modifiers.size() > 0) {
previous_printwriter = collector;
sw = new StringWriter();
collector = new PrintWriter(sw);
}
List<TemplateDictionary> child_dicts = dict.getChildDicts(includeName);
if (child_dicts.size() == 0) {
incl_tmpl.render(dict, collector);
} else {
for (TemplateDictionary subdict : child_dicts) {
incl_tmpl.render(subdict, collector);
}
}
if (previous_printwriter != null) {
String results = sw.toString();
collector = previous_printwriter;
collector.write(Modifiers.applyModifiers(results, modifiers));
}
}