@SuppressWarnings("unchecked")
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
BeanModel activityModel = (BeanModel) params.get("activity");
Activity activity = activityModel!=null ? (Activity) activityModel.getWrappedObject() : null;
Assert.notNull(activity, "Render target activity can not be null!");
if(Activity.FORMAT_FTL.equals(activity.getFormat())) {
Object requestModel = env.getDataModel().get("Request");
String base = ((HttpRequestHashModel) requestModel).getRequest().getContextPath();
Template template = env.getConfiguration().getTemplate(activity.getDescription());
Map<Object, Object> model = createModel(activity);
model.put("base", base);
String result = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
env.getOut().write(result);
} else if(Activity.FORMAT_TXT.equals(activity.getFormat())) {
String imageBase = params.get("imageBase").toString();
Assert.notNull(imageBase, "Parameter imageBase can not be null when format is txt...");
String text = parseFace(imageBase, activity.getDescription());
text = parseImage(text);
text = parseLink(text);
text = parseSpecialChar(text);
env.getOut().write(text);
} else if(Activity.FORMAT_HTML.equals(activity.getFormat())) {
env.getOut().write(activity.getDescription());
} else {
env.getOut().write(activity.getDescription());
}
}