Skip to content

Add inline JSON input for the render CLI #5

Description

@servletcloud

Problem

fstache render currently accepts JSON render data only through --data PATH:

fstache render --data data.json < page.mustache > page.html

That works for files, but it is awkward for quick one-off renders, smoke tests, docs examples, and shell scripts that already have a small JSON object available inline.

Users have to create a temporary file or use shell-specific process substitution instead of writing the data directly in the command.

Proposed CLI

Add an inline JSON option, for example:

fstache render --json {"name":"Ada"} < page.mustache

--data PATH should remain the file-based option.

Design questions

  • Should --json and --data be mutually exclusive?
  • Should --json - mean read JSON from stdin, or should stdin stay reserved for the template?
  • Should invalid inline JSON reuse the same diagnostic style as invalid --data files?

Expected behavior

  • Inline JSON is parsed as the render data object.
  • Invalid inline JSON exits non-zero without a traceback.
  • The existing --data PATH behavior remains unchanged.
  • The README CLI section documents the new option with a short example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions