use of com.google.template.soy.pysrc.restricted.PyFunctionExprBuilder in project closure-templates by google.
the class AugmentMapFunction method computeForPySrc.
@Override
public PyExpr computeForPySrc(List<PyExpr> args) {
PyFunctionExprBuilder fnBuilder = new PyFunctionExprBuilder("dict");
fnBuilder.addArg(args.get(0)).setUnpackedKwargs(args.get(1));
return fnBuilder.asPyExpr();
}
use of com.google.template.soy.pysrc.restricted.PyFunctionExprBuilder in project closure-templates by google.
the class TruncateDirective method applyForPySrc.
@Override
public PyExpr applyForPySrc(PyExpr value, List<PyExpr> args) {
// Truncation always wants a string, so to potentially save an unnecessary conversion, we do
// optional coercing at compile time.
PyExpr input = value.toPyString();
PyExpr maxLen = args.get(0);
PyExpr doAddEllipsis = (args.size() == 2) ? args.get(1) : new PyExpr("True", Integer.MAX_VALUE);
PyFunctionExprBuilder fnBuilder = new PyFunctionExprBuilder("directives.truncate");
fnBuilder.addArg(input).addArg(maxLen).addArg(doAddEllipsis);
return fnBuilder.asPyStringExpr();
}
Aggregations