|
1 | 1 | package de.neuland.pug4j.template; |
2 | 2 |
|
3 | 3 | import de.neuland.pug4j.Pug4J.Mode; |
| 4 | +import de.neuland.pug4j.PugConfiguration; |
| 5 | +import de.neuland.pug4j.PugEngine; |
| 6 | +import de.neuland.pug4j.RenderContext; |
| 7 | +import de.neuland.pug4j.compiler.Compiler; |
| 8 | +import de.neuland.pug4j.exceptions.PugCompilerException; |
| 9 | +import de.neuland.pug4j.model.PugModel; |
4 | 10 | import de.neuland.pug4j.parser.node.DoctypeNode; |
5 | 11 | import de.neuland.pug4j.parser.node.Node; |
| 12 | +import java.io.Writer; |
6 | 13 |
|
| 14 | +@SuppressWarnings({"deprecation", "removal"}) |
7 | 15 | public class PugTemplate { |
8 | 16 |
|
9 | 17 | private Node rootNode; |
@@ -46,4 +54,27 @@ private void setDoctype(String name) { |
46 | 54 | this.terse = "html".equals(name); |
47 | 55 | this.xml = "xml".equals(name); |
48 | 56 | } |
| 57 | + |
| 58 | + /** |
| 59 | + * Deprecated in favor of rendering via PugEngine/RenderContext. |
| 60 | + * |
| 61 | + * @deprecated Since 3.0.0, forRemoval = true. Use PugEngine#render instead. |
| 62 | + */ |
| 63 | + @Deprecated(since = "3.0.0", forRemoval = true) |
| 64 | + @SuppressWarnings("deprecation") |
| 65 | + public void process(PugModel model, Writer writer, PugConfiguration pugConfiguration) |
| 66 | + throws PugCompilerException { |
| 67 | + // Bridge deprecated PugConfiguration to the new rendering pipeline |
| 68 | + PugEngine engine = pugConfiguration.getOrCreateEngine(); |
| 69 | + |
| 70 | + RenderContext context = |
| 71 | + RenderContext.builder() |
| 72 | + .prettyPrint(pugConfiguration.isPrettyPrint()) |
| 73 | + .defaultMode(pugConfiguration.getMode()) |
| 74 | + .globalVariables(pugConfiguration.getSharedVariables()) |
| 75 | + .build(); |
| 76 | + |
| 77 | + Compiler compiler = new Compiler(this, context, engine); |
| 78 | + compiler.compile(model, writer); |
| 79 | + } |
49 | 80 | } |
0 commit comments