MCPcopy Create free account
hub / github.com/xmlet/HtmlFlow / HtmlFlow

Class HtmlFlow

htmlflow-core/src/main/java/htmlflow/HtmlFlow.java:40–529  ·  view source on GitHub ↗

Factory to create HtmlDoc or HtmlView instances corresponding to static HTMl pages or dynamic pages. HtmlView objects depend on a model.

Source from the content-addressed store, hash-verified

38 * pages. HtmlView objects depend on a model.
39 */
40public class HtmlFlow {
41
42 /** Make private constructor to forbid instantiation. */
43 private HtmlFlow() {}
44
45 /**
46 * This will invoke the HtmlTemplate to a PreprocessingVisitor that collects a chain of
47 * HtmlContinuation objects containing the static HTML strings and dynamic HTML consumers.
48 *
49 * @param template An HtmlTemplate function, which depends on an HtmlView used to create HTMl
50 * elements.
51 * @param isIndented Set indentation on or off.
52 */
53 private static PreprocessingVisitor preprocessing(
54 HtmlTemplate template,
55 boolean isIndented
56 ) {
57 PreprocessingVisitor pre = new PreprocessingVisitor(isIndented);
58 HtmlView<?> preView = new HtmlView<>(() -> pre, template, false);
59 /*
60 * 1st Performs rendering by invoking the function defined as the template, collecting the
61 * resulting static HTML into an internal StringBuffer.
62 */
63 template.resolve(preView);
64 /*
65 * NO problem with null model. We are just preprocessing static HTML blocks.
66 * Thus, dynamic blocks which depend on model are not invoked.
67 * 2nd Simply invokes resolve in PreprocessingVisitor, which creates only
68 * the final HtmlContinuationSyncStatic containing the remaining static HTML
69 * accumulated in the internal StringBuffer out.
70 */
71 preView.getVisitor().resolve(null);
72 return pre;
73 }
74
75 /**
76 * Performs preprocessing for Micro Frontend (MFE) views. Creates a specialized visitor that collects
77 * MFE configurations and processes them to enable MFE support in the view.
78 *
79 * @param template An HtmlTemplate function that defines the HTML structure with MFE components
80 * @return A PreprocessingVisitorMfe containing the processed MFE components
81 */
82 private static PreprocessingVisitorMfe preprocessingMfe(
83 HtmlTemplate template
84 ) {
85 PreprocessingVisitorMfe processView = new PreprocessingVisitorMfe(
86 false
87 );
88 HtmlView<?> preView = new HtmlView<>(
89 () -> processView,
90 template,
91 false
92 );
93 // first process
94 template.resolve(preView);
95 // second process
96 preView.getVisitor().resolve(null);
97 return processView;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected