use of freemarker.template.SimpleScalar in project android by JetBrains.
the class FmExtractLettersMethodTest method check.
@SuppressWarnings("rawtypes")
private void check(String s, String expected) throws TemplateModelException {
FmExtractLettersMethod method = new FmExtractLettersMethod();
List list = Collections.singletonList(new SimpleScalar(s));
assertEquals(expected, ((SimpleScalar) method.exec(list)).getAsString());
}
use of freemarker.template.SimpleScalar in project android by JetBrains.
the class FmActivityToLayoutMethodTest method check.
@SuppressWarnings("rawtypes")
private static void check(String s, String expected) throws TemplateModelException {
FmActivityToLayoutMethod method = new FmActivityToLayoutMethod();
List list = Collections.singletonList(new SimpleScalar(s));
assertEquals(expected, ((SimpleScalar) method.exec(list)).getAsString());
}
use of freemarker.template.SimpleScalar in project android by JetBrains.
the class FmCamelCaseToUnderscoreMethodTest method check.
@SuppressWarnings("rawtypes")
private void check(String s, String expected) throws TemplateModelException {
FmCamelCaseToUnderscoreMethod method = new FmCamelCaseToUnderscoreMethod();
List list = Collections.singletonList(new SimpleScalar(s));
assertEquals(expected, ((SimpleScalar) method.exec(list)).getAsString());
}
use of freemarker.template.SimpleScalar in project leopard by tanhaichao.
the class AbstractTemplateMethod method exec.
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
// arguments.toArray();
Object[] args = new Object[arguments.size()];
int i = 0;
for (Object obj : arguments) {
if (obj != null) {
if (obj instanceof SimpleDate) {
args[i] = ((SimpleDate) obj).getAsDate();
} else if (obj instanceof SimpleNumber) {
args[i] = ((SimpleNumber) obj).getAsNumber();
} else if (obj instanceof SimpleNumber) {
args[i] = ((SimpleNumber) obj).getAsNumber();
} else if (obj instanceof SimpleScalar) {
args[i] = ((SimpleScalar) obj).toString();
} else if (obj instanceof StringModel) {
args[i] = ((StringModel) obj);
} else {
logger.error("obj:" + obj.getClass());
args[i] = obj.toString();
}
}
i++;
}
try {
return this.execute(args);
} catch (TemplateModelException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new TemplateModelException(e.getMessage(), e);
}
}
use of freemarker.template.SimpleScalar in project leopard by tanhaichao.
the class BodyTemplateDirective method execute.
@Override
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
// String folder = ((SimpleScalar) params.get("template_folder")).getAsString();
String templateName = ((SimpleScalar) params.get("template_name")).getAsString();
// String templateName = (String) params.get("template_name");
Template template = env.getConfiguration().getTemplate(templateName + ".ftl");
template.process(DATA.get(), env.getOut());
}
Aggregations