Skip to content

Feature Request: Preprocessor mode to merge/inline partials as raw Liquid code with scoped contexts #949

Description

@vikaskandari

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions