本文整理汇总了Java中com.mitchellbosecke.pebble.node.BodyNode类的典型用法代码示例。如果您正苦于以下问题:Java BodyNode类的具体用法?Java BodyNode怎么用?Java BodyNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BodyNode类属于com.mitchellbosecke.pebble.node包,在下文中一共展示了BodyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public RenderableNode parse(Token token, Parser parser) throws ParserException {
TokenStream stream = parser.getStream();
int lineNumber = token.getLineNumber();
// skip the 'parallel' token
stream.next();
stream.expect(Token.Type.EXECUTE_END);
BodyNode body = parser.subparse(decideParallelEnd);
// skip the 'endparallel' token
stream.next();
stream.expect(Token.Type.EXECUTE_END);
return new ParallelNode(lineNumber, body);
}
示例2: visit
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public void visit(BodyNode node) {
write("body");
level++;
super.visit(node);
level--;
}
示例3: visit
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public void visit(IfNode node) {
for (Pair<Expression<?>, BodyNode> pairs : node.getConditionsWithBodies()) {
pairs.getLeft().accept(this);
pairs.getRight().accept(this);
}
if (node.getElseBody() != null) {
node.getElseBody().accept(this);
}
}
示例4: parse
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public RenderableNode parse(Token token, Parser parser) throws ParserException {
TokenStream stream = parser.getStream();
int lineNumber = token.getLineNumber();
// skip the 'filter' token
stream.next();
List<Expression<?>> filterInvocationExpressions = new ArrayList<>();
filterInvocationExpressions.add(parser.getExpressionParser().parseFilterInvocationExpression());
while(stream.current().test(Type.OPERATOR, "|")){
// skip the '|' token
stream.next();
filterInvocationExpressions.add(parser.getExpressionParser().parseFilterInvocationExpression());
}
stream.expect(Token.Type.EXECUTE_END);
BodyNode body = parser.subparse(endFilter);
stream.next();
stream.expect(Token.Type.EXECUTE_END);
Expression<?> lastExpression = new RenderableNodeExpression(body, stream.current().getLineNumber());
for(Expression<?> filterInvocationExpression : filterInvocationExpressions){
FilterExpression filterExpression = new FilterExpression();
filterExpression.setRight(filterInvocationExpression);
filterExpression.setLeft(lastExpression);
lastExpression = filterExpression;
}
return new PrintNode(lastExpression, lineNumber);
}
示例5: parseBody
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
private Expression<?> parseBody(TokenStream stream, Parser parser) throws ParserException {
List<Expression<?>> filterInvocationExpressions = new ArrayList<>();
if(stream.current().test(Token.Type.PUNCTUATION, ":")) {
stream.next();
stream.expect(Token.Type.PUNCTUATION, ":");
filterInvocationExpressions.add(parser.getExpressionParser().parseFilterInvocationExpression());
while(stream.current().test(Token.Type.OPERATOR, "|")){
// skip the '|' token
stream.next();
filterInvocationExpressions.add(parser.getExpressionParser().parseFilterInvocationExpression());
}
}
stream.expect(Token.Type.EXECUTE_END);
BodyNode body = parser.subparse(token -> token.test(Token.Type.NAME, "end" + name));
stream.next();
stream.expect(Token.Type.EXECUTE_END);
Expression<?> lastExpression = new RenderableNodeExpression(body, stream.current().getLineNumber());
for(Expression<?> filterInvocationExpression : filterInvocationExpressions){
FilterExpression filterExpression = new FilterExpression();
filterExpression.setRight(filterInvocationExpression);
filterExpression.setLeft(lastExpression);
lastExpression = filterExpression;
}
return lastExpression;
}
示例6: parse
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public RenderableNode parse(Token token, Parser parser) throws ParserException {
TokenStream stream = parser.getStream();
int lineNumber = token.getLineNumber();
// skip the 'for' token
stream.next();
// get the iteration variable
String iterationVariable = parser.getExpressionParser().parseNewVariableName();
stream.expect(Token.Type.NAME, "in");
// get the iterable variable
Expression<?> iterable = parser.getExpressionParser().parseExpression();
stream.expect(Token.Type.EXECUTE_END);
BodyNode body = parser.subparse(this.decideForFork);
BodyNode elseBody = null;
if (stream.current().test(Token.Type.NAME, "else")) {
// skip the 'else' token
stream.next();
stream.expect(Token.Type.EXECUTE_END);
elseBody = parser.subparse(this.decideForEnd);
}
if (stream.current().getValue() == null) {
throw new ParserException(
null,
"Unexpected end of template. Pebble was looking for the \"endfor\" tag",
stream.current().getLineNumber(), stream.getFilename());
}
// skip the 'endfor' token
stream.next();
stream.expect(Token.Type.EXECUTE_END);
return new ForNode(lineNumber, iterationVariable, iterable, body, elseBody);
}
示例7: parse
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public RenderableNode parse(Token token, Parser parser) throws ParserException {
TokenStream stream = parser.getStream();
// skip over the 'macro' token
stream.next();
String macroName = stream.expect(Token.Type.NAME).getValue();
ArgumentsNode args = parser.getExpressionParser().parseArguments(true);
stream.expect(Token.Type.EXECUTE_END);
// parse the body
BodyNode body = parser.subparse(decideMacroEnd);
// skip the 'endmacro' token
stream.next();
stream.expect(Token.Type.EXECUTE_END);
return new MacroNode(macroName, args, body);
}
示例8: parse
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
@Override
public RenderableNode parse(Token token, Parser parser) throws ParserException {
TokenStream stream = parser.getStream();
int lineNumber = token.getLineNumber();
// skip the 'if' token
stream.next();
List<Pair<Expression<?>, BodyNode>> conditionsWithBodies = new ArrayList<>();
Expression<?> expression = parser.getExpressionParser().parseExpression();
stream.expect(Token.Type.EXECUTE_END);
BodyNode body = parser.subparse(this.decideIfFork);
conditionsWithBodies.add(new Pair<Expression<?>, BodyNode>(expression, body));
BodyNode elseBody = null;
boolean end = false;
while (!end) {
if (stream.current().getValue() == null) {
throw new ParserException(
null,
"Unexpected end of template. Pebble was looking for the \"endif\" tag",
stream.current().getLineNumber(), stream.getFilename());
}
switch (stream.current().getValue()) {
case "else":
stream.next();
stream.expect(Token.Type.EXECUTE_END);
elseBody = parser.subparse(this.decideIfEnd);
break;
case "elseif":
stream.next();
expression = parser.getExpressionParser().parseExpression();
stream.expect(Token.Type.EXECUTE_END);
body = parser.subparse(this.decideIfFork);
conditionsWithBodies.add(new Pair<Expression<?>, BodyNode>(expression, body));
break;
case "endif":
stream.next();
end = true;
break;
default:
throw new ParserException(
null,
"Unexpected end of template. Pebble was looking for the following tags \"else\", \"elseif\", or \"endif\"",
stream.current().getLineNumber(), stream.getFilename());
}
}
stream.expect(Token.Type.EXECUTE_END);
return new IfNode(lineNumber, conditionsWithBodies, elseBody);
}
示例9: HasRoleNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public HasRoleNode(int lineNumber, Expression<?> value, BodyNode body) {
super(lineNumber);
this.value = value;
this.body = body;
}
示例10: LacksRoleNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public LacksRoleNode(int lineNumber, Expression<?> value, BodyNode body) {
super(lineNumber);
this.value = value;
this.body = body;
}
示例11: LacksPermissionNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public LacksPermissionNode(int lineNumber, Expression<?> value, BodyNode body) {
super(lineNumber);
this.value = value;
this.body = body;
}
示例12: GuestNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public GuestNode(int lineNumber, BodyNode body) {
super(lineNumber);
this.body = body;
}
示例13: HasAllRolesNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public HasAllRolesNode(int lineNumber, Expression<?> value, BodyNode body) {
super(lineNumber);
this.value = value;
this.body = body;
}
示例14: UserNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public UserNode(int lineNumber, BodyNode body) {
super(lineNumber);
this.body = body;
}
示例15: HasAnyRolesNode
import com.mitchellbosecke.pebble.node.BodyNode; //导入依赖的package包/类
public HasAnyRolesNode(int lineNumber, Expression<?> value, BodyNode body) {
super(lineNumber);
this.value = value;
this.body = body;
}