Exploring an AST-Based Template Engine in PHP — Thoughts?

I’ve been exploring an idea and would really like to hear different perspectives on it. What if a PHP template engine (like Blade) moved from being string-based to an AST-driven pipeline (lexer → p...

By · · 1 min read
Exploring an AST-Based Template Engine in PHP — Thoughts?

Source: DEV Community

I’ve been exploring an idea and would really like to hear different perspectives on it. What if a PHP template engine (like Blade) moved from being string-based to an AST-driven pipeline (lexer → parser → AST), so it actually understands the structure of the template instead of just compiling it? The thought is that this could produce a tree representation of the view (some kind of server-side VDOM). With that, it might be possible to clearly separate static and dynamic parts based on AST analysis. In theory, instead of re-rendering the full HTML on every request, the server could work at a node level: identify which parts are dynamic track them as nodes in a tree and update only those parts when data changes Something conceptually similar to how virtual DOM works in frameworks like Vue, but driven from the server side. For example: dynamic variables could be detected at compile time certain values could be marked as “live” the browser could request only those live parts (e.g. via smal

Similar Topics

#ai (16747) #open source (1686) #webdev (254) #javascript (229) #architecture (108) #react (63) #monitoring (18) #backend (16) #programming (3999) #python (1819) #api (110) #showdev (66) #agenticsystems (14) #agents (241) #opensource (171) #cli (47) #node.js (37) #release radar (30) #mishmanners (14) #github game off (8)

Related Posts

Trending on ShareHub

Latest on ShareHub

Browse Topics

#artificial intelligence (31552) #data science (24017) #ai (16738) #generative ai (15034) #crypto (14987) #machine learning (14680) #bitcoin (14229) #featured (13550) #news & insights (13064) #crypto news (11082)

Around the Network