It would be useful to have a method that merges Liquid templates into a single self-contained Liquid source string, where all {% render %}, {% include %}, {% layout %}, and {% extends %} tags are replaced with the actual source code of the referenced templates (with proper variable scoping).
Example:
header.liquid
<header>{{ title }}</header>
home.liquid
<body>{% render 'header', title: 'hello world' %}</body>
Desired output (Liquid string):
<body>
{% assign __header_title = 'hello world' %}
<header>{{ __header_title }}</header>
</body>
Use Case: Serverless environments like Cloudflare Workers where file system access isn't available at runtime. This would allow bundling all templates into a single string during build.
Proposed API:
const merged = await liquid.merge('home.liquid');
// Returns Liquid source string with all partials inlined
It would be useful to have a method that merges Liquid templates into a single self-contained Liquid source string, where all
{% render %},{% include %},{% layout %}, and{% extends %}tags are replaced with the actual source code of the referenced templates (with proper variable scoping).Example:
header.liquidhome.liquidDesired output (Liquid string):
Use Case: Serverless environments like Cloudflare Workers where file system access isn't available at runtime. This would allow bundling all templates into a single string during build.
Proposed API: