Skip to content

BPS-10: Render templates with mustache.js and fix unset tags - #57

Merged
krugazul merged 3 commits into
developfrom
fix/bps-10-mustache-placeholders
Oct 28, 2026
Merged

krugazul merged 3 commits into
developfrom
fix/bps-10-mustache-placeholders

Conversation

@krugazul

Copy link
Copy Markdown
Contributor

Part of BPS-10 (#55): the Mustache placeholder review. The generator now renders templates with mustache.js, and the review fixed the tags that were rendering empty. The generated-plugin side is in lightspeedwp/ls-test (fix/bps-10-mustache-placeholders).

Rendering with mustache.js (d0b760b)

  • Filters are mustache dotted names. mustache.js has no filter syntax, so the view holds one object per filter: {{namespace|upper}} is now {{upper.namespace}}, and the same for lower, pascalCase, camelCase, kebabCase, snakeCase and title. Before, title returned the value unchanged; now it title-cases. All template uses, docs, tests and helper scripts are converted.
  • No HTML escaping. The templates are PHP, JavaScript, JSON and Markdown.
  • A tag with no value fails generation, listing each file and tag, instead of rendering an empty string. author_uri is the only optional tag (the config schema requires a URL, so it can't default to empty).
  • plugin-template/.github/workflows/ is copied without rendering, so mustache.js leaves the ${{ github.* }} expressions alone. release.yml reads the slug from package.json (f4f5d12).
  • Template mode (--in-place) renders only plugin-template/. Before, it also rendered the scaffold's own docs and workflows.
  • mustache ^4.2.0 is added as a devDependency. The lockfile gains only its entry; npm install also wanted to prune an unrelated subtree, which I left out.

Tags that rendered empty (76ec47c, d0b760b)

  • {{taxonomy_slug}} and {{post_type_slug}} were never set, so content-model plugins shipped QueryControls, TaxonomyFilter, PostSelector and useTaxonomies with an empty taxonomy or post type. They now get the first taxonomy and post type, or category and post. TaxonomyFilter also defaulted to <taxonomy>_category, which is never registered.
  • {{pot_date}} was never set, so every .pot file had an empty POT-Creation-Date.
  • src/utils/query.js defaulted to an empty post type, and a content-model plugin with no post types rendered pattern slugs and field group locations with an empty post type. Both now use the first post type, or post. In functional-only plugins, the example field groups still attach to no post type.
  • QueryControls keys taxQuery by a TAXONOMY constant. With a real taxonomy, taxQuery?.[ 'region' ] failed ESLint's dot-notation rule, and a slug with a hyphen needs brackets.
  • The generated DEVELOPMENT.md lists the plugin's names instead of the template tag syntax, which means nothing inside a plugin.

Testing

  • node scripts/toolchain/check-generation.js: both fixtures pass generate, leftover check, install, build, every lint step and test:unit.
  • Round trip: compare-toolchain.js finds no differences between a freshly generated ls-test and the ls-test branch.
  • Template mode on a throwaway copy of the scaffold: the plugin renders with no tags left, its workflows are byte-identical to the template's, and the scaffold's own docs are untouched.
  • npx jest scripts: no failing test that does not already fail on develop. New tests cover dotted filters, no escaping, findUnsetTags() and unrendered workflows.

Not changed

scripts/mustache-variables-registry.json and its scanner cover the whole repository and are not used by the generator, so the registry still lists the old name|filter forms until it is regenerated.

🤖 Generated with Claude Code

krugazul and others added 3 commits October 28, 2026 16:02
These tags had no value, so content-model plugins shipped QueryControls,
TaxonomyFilter and PostSelector with empty taxonomy and post type defaults,
and every .pot had an empty creation date. TaxonomyFilter's default also
appended _category to the slug, a taxonomy that is never registered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moved back from lightspeedwp/ls-test. The workflow no longer holds template
tags, so the generator can copy it without rendering (BPS-10).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BPS-10 Mustache placeholder review. Templates render with mustache.js
(escaping off). Filters become dotted names ({{upper.namespace}}), a tag
with no value fails generation, workflows are copied without rendering,
and template mode renders only plugin-template/. The audit's fixes:
query.js and content-model plugins without post types defaulted to an
empty post type, and QueryControls now keys taxQuery by a constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

BPS-10

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Note

Some coding-guideline sources were skipped; the reason is listed next to each one. Other guidelines were applied as usual. On a public repository, sources from your configuration are listed without their names.

Skipped guideline sources: 1
a configured source — couldn't be fetched
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Comment @coderabbitai help to get the list of available commands.

@krugazul
krugazul marked this pull request as ready for review October 28, 2026 14:37
@krugazul
krugazul merged commit 9b76eb7 into develop Oct 28, 2026
5 of 19 checks passed
@krugazul
krugazul deleted the fix/bps-10-mustache-placeholders branch October 28, 2026 14:38
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.

1 participant