本文整理汇总了Java中com.mitchellbosecke.pebble.extension.Function类的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Function类属于com.mitchellbosecke.pebble.extension包,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
return Collections.<String, Function>singletonMap("bad", new Function() {
@Override
public List<String> getArgumentNames() {
return null;
}
@Override
public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {
return "<script>alert(\"injection\");</script>";
}
});
}
示例2: evaluate
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Object evaluate(PebbleTemplateImpl self, EvaluationContextImpl context) throws PebbleException {
Function function = context.getExtensionRegistry().getFunction(this.functionName);
if (function != null) {
return this.applyFunction(self, context, function, this.args);
}
return self.macro(context, this.functionName, this.args, false, this.lineNumber);
}
示例3: applyFunction
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
private Object applyFunction(PebbleTemplateImpl self, EvaluationContextImpl context, Function function,
ArgumentsNode args) throws PebbleException {
List<Object> arguments = new ArrayList<>();
Collections.addAll(arguments, args);
Map<String, Object> namedArguments = args.getArgumentMap(self, context, function);
return function.execute(namedArguments, self, context, this.getLineNumber());
}
示例4: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put(MessageSourceFunction.FUNCTION_NAME, new MessageSourceFunction(this.messageSource));
functions.put(HasErrorsFunction.FUNCTION_NAME, new HasErrorsFunction());
functions.put(HasGlobalErrorsFunction.FUNCTION_NAME, new HasGlobalErrorsFunction());
functions.put(HasFieldErrorsFunction.FUNCTION_NAME, new HasFieldErrorsFunction());
functions.put(GetAllErrorsFunction.FUNCTION_NAME, new GetAllErrorsFunction(this.messageSource));
functions.put(GetGlobalErrorsFunction.FUNCTION_NAME, new GetGlobalErrorsFunction(this.messageSource));
functions.put(GetFieldErrorsFunction.FUNCTION_NAME, new GetFieldErrorsFunction(this.messageSource));
functions.put(HrefFunction.FUNCTION_NAME, new HrefFunction());
return functions;
}
示例5: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functionMap = new HashMap<>();
for (TemplateFunction function : templateFunctions) {
functionMap.put(function.getName(), new PebbleWrapperTemplateFunction(
contextProvider,
function.getName(),
Arrays.asList(function.parameters()),
function.getClass()));
}
return functionMap;
}
示例6: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> f = new HashMap<>();
f.put("messageWithBundle", new MessageFunction(configuration, Optional.empty()));
f.put("message", new MessageFunction(configuration, Optional.of("messages")));
f.put("fromMap", new FromMapFunction());
f.put("defaultOrLocale", new DefaultOrLocale());
f.put("switchToLocale", new SwitchToLocale());
return f;
}
示例7: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
/**
* Provide 't' function, which use message source
*/
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put("t", new TranslateFunction(messageSource));
return functions;
}
示例8: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put("i18n", new I18NFunction());
functions.put("range", new RangeFunction());
functions.put("entries", new MapEntriesFunction());
functions.put("getValue", new MapValueFunction());
return functions;
}
示例9: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put("i18n", new i18nFunction());
return functions;
}
示例10: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<String, Function>();
functions.put("testFunction", new TestFunction());
return functions;
}
示例11: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
return Collections.EMPTY_MAP;
}
示例12: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
return null;
}
示例13: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>(1);
functions.put("principal", new PrincipalFunction());
return functions;
}
示例14: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put("i18n", new I18nFunction());
return functions;
}
示例15: getFunctions
import com.mitchellbosecke.pebble.extension.Function; //导入依赖的package包/类
@Override
public Map<String, Function> getFunctions() {
Map<String, Function> functions = new HashMap<>();
functions.put("ng", new NgFunction());
return functions;
}