本文整理匯總了Java中com.mitchellbosecke.pebble.extension.NodeVisitorFactory類的典型用法代碼示例。如果您正苦於以下問題:Java NodeVisitorFactory類的具體用法?Java NodeVisitorFactory怎麽用?Java NodeVisitorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NodeVisitorFactory類屬於com.mitchellbosecke.pebble.extension包,在下文中一共展示了NodeVisitorFactory類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPebbleTemplate
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
private PebbleTemplate getPebbleTemplate(final PebbleEngine self, final String templateName, final Object cacheKey) throws LoaderException, ParserException {
LexerImpl lexer = new LexerImpl(syntax, extensionRegistry.getUnaryOperators().values(),
extensionRegistry.getBinaryOperators().values());
Reader templateReader = self.retrieveReaderFromLoader(self.loader, cacheKey);
TokenStream tokenStream = lexer.tokenize(templateReader, templateName);
Parser parser = new ParserImpl(extensionRegistry.getUnaryOperators(),
extensionRegistry.getBinaryOperators(), extensionRegistry.getTokenParsers());
RootNode root = parser.parse(tokenStream);
PebbleTemplateImpl instance = new PebbleTemplateImpl(self, root, templateName);
for (NodeVisitorFactory visitorFactory : extensionRegistry.getNodeVisitors()) {
visitorFactory.createVisitor(instance).visit(root);
}
return instance;
}
示例2: compile
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
@Override
public String compile(String extension, String source, Map<String, Object> data) {
try {
LexerImpl lexer = new LexerImpl(
engine.getSyntax(),
engine.getExtensionRegistry().getUnaryOperators().values(),
engine.getExtensionRegistry().getBinaryOperators().values());
TokenStream tokenStream = lexer.tokenize(new StringReader(source), "");
Parser parser = new ParserImpl(
engine.getExtensionRegistry().getUnaryOperators(),
engine.getExtensionRegistry().getBinaryOperators(),
engine.getExtensionRegistry().getTokenParsers());
RootNode root = parser.parse(tokenStream);
PebbleTemplateImpl compiledTemplate = new PebbleTemplateImpl(engine, root, "");
for (NodeVisitorFactory visitorFactory : engine.getExtensionRegistry().getNodeVisitors()) {
visitorFactory.createVisitor(compiledTemplate).visit(root);
}
Writer writer = new StringWriter();
compiledTemplate.evaluate(writer, data);
return writer.toString();
}
catch (Exception e) {
e.printStackTrace();
}
return source;
}
示例3: getNodeVisitors
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
public List<NodeVisitorFactory> getNodeVisitors() {
List<NodeVisitorFactory> visitors = new ArrayList<>();
visitors.add(prettyPrinter);
return visitors;
}
示例4: getNodeVisitors
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
@Override
public List<NodeVisitorFactory> getNodeVisitors() {
List<NodeVisitorFactory> visitors = new ArrayList<>();
visitors.add(visitorFactory);
return visitors;
}
示例5: getNodeVisitors
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
@Override
public List<NodeVisitorFactory> getNodeVisitors() {
return Collections.EMPTY_LIST;
}
示例6: getNodeVisitors
import com.mitchellbosecke.pebble.extension.NodeVisitorFactory; //導入依賴的package包/類
@Override
public List<NodeVisitorFactory> getNodeVisitors() {
return null;
}