All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mitchellbosecke.pebble.node.FromNode Maven / Gradle / Ivy

There is a newer version: 3.2.2
Show newest version
package com.mitchellbosecke.pebble.node;

import com.mitchellbosecke.pebble.extension.NodeVisitor;
import com.mitchellbosecke.pebble.node.expression.Expression;
import com.mitchellbosecke.pebble.template.EvaluationContextImpl;
import com.mitchellbosecke.pebble.template.PebbleTemplateImpl;
import com.mitchellbosecke.pebble.utils.Pair;
import java.io.Writer;
import java.util.List;

/**
 * From Node for
 *
 * 

{% from "templateName" import macroName as alias %}

* * @author yanxiyue */ public class FromNode extends AbstractRenderableNode { private final Expression fromExpression; private final List> namedMacros; public FromNode(int lineNumber, Expression fromExpression, List> namedMacros) { super(lineNumber); this.fromExpression = fromExpression; this.namedMacros = namedMacros; } @Override public void render(PebbleTemplateImpl self, Writer writer, EvaluationContextImpl context) { String templateName = (String) fromExpression.evaluate(self, context); self.importNamedMacrosFromTemplate(templateName, namedMacros); } @Override public void accept(NodeVisitor visitor) { visitor.visit(this); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy