Skip to content

feat: extend --html-folder to serve local JSON form definitions on-the-fly#2707

Closed
navneet-ag wants to merge 4 commits intoadobe:mainfrom
navneet-ag:main
Closed

feat: extend --html-folder to serve local JSON form definitions on-the-fly#2707
navneet-ag wants to merge 4 commits intoadobe:mainfrom
navneet-ag:main

Conversation

@navneet-ag
Copy link
Copy Markdown

@navneet-ag navneet-ag commented Apr 15, 2026

Extends the existing --html-folder mechanism to also resolve .json files,
rendering them as AEM form block HTML on-the-fly without requiring a publish step.

When a request hits the html-folder handler and no .html or .plain.html file
is found, it falls back to a .json file and calls generateFormPageHtml() to
produce the standard form block structure the client-side form script expects.

Resolution priority: .html > .plain.html > .json

Usage:

aem up --html-folder forms --html-mount /content/forms/af/

Replaces the previously proposed --local-forms / --local-forms-mount flags
based on reviewer feedback.

Related Issues

Thanks for contributing!

…ublishing

Adds --local-forms and --local-forms-mount flags to `aem up` so forms can be
rendered locally from JSON files without requiring a publish step. The server
constructs the standard AEM form page HTML and lets client-side scripts handle
rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/server/HelixServer.js Fixed
@tripodsan
Copy link
Copy Markdown
Contributor

this use case can be covered with the --html-folder. I don't think we should add markup source provider specific rendering in this CLI.

Navneet Agarwal and others added 2 commits April 22, 2026 10:09
Remove the --local-forms and --local-forms-mount flags and extend the
existing --html-folder mechanism to resolve .json files on-the-fly,
rendering them as AEM form block HTML via generateFormPageHtml().

Resolution priority: .html > .plain.html > .json

Users migrate from:
  aem up --local-forms forms
to:
  aem up --html-folder forms --html-mount /content/forms/af/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@navneet-ag navneet-ag changed the title feat: add --local-forms flag to serve forms from local JSON without publishing feat: extend --html-folder to serve local JSON form definitions on-the-fly Apr 22, 2026
@navneet-ag navneet-ag marked this pull request as ready for review April 22, 2026 04:43
Copy link
Copy Markdown
Contributor

@tripodsan tripodsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json is used to store sheets and should not be rendered differently. I don't see why the server should transform it into html

Extend the --html-folder handler to serve files with extensions
(e.g. .json) as-is from the folder. This enables the anchor tag
pattern for forms: an HTML page references a local JSON file via
<a href>, and the form block JS fetches it at runtime.

Removes the JSON-to-HTML transform (generateFormPageHtml) since
the server should not perform markup-specific rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@navneet-ag
Copy link
Copy Markdown
Author

@tripodsan Agreed — removed the JSON→HTML transform completely. The server no longer renders JSON differently.

The only remaining change: --html-folder now serves static files (like .json) as-is from the folder. This enables a local
form dev workflow where the HTML uses <a href="/forms/def.json"> and the form block JS fetches the JSON
at runtime. I can edit the JSON and see changes immediately without touching the HTML.

@navneet-ag navneet-ag requested a review from tripodsan April 27, 2026 07:02
Comment thread src/server/HelixServer.js
* @param {string} relativePath path relative to HTML folder
*/
async serveHtmlFolderStaticFile(req, res, next, relativePath) {
if (relativePath.includes('/../') || relativePath.includes('..')) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need both checks ? isn't ..` sufficient?

@tripodsan tripodsan self-assigned this Apr 27, 2026
@tripodsan tripodsan mentioned this pull request Apr 27, 2026
@tripodsan
Copy link
Copy Markdown
Contributor

merge with #2717

@tripodsan tripodsan closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants