Phase 4: LiquidJS 模板渲染集成 #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
目标
集成 LiquidJS 引擎,支持自定义模板渲染 +
rendertag 递归。交付物
4.1 LiquidJS 依赖引入
liquidjs到packages/json-cas依赖4.2 自定义
rendertag{% render child, decay: 0.7 %}— 按指定衰减渲染子节点4.3 模板上下文变量
resolution— 当前节点分辨率epsilon— 剪枝阈值hash— 当前节点 hashpayload— 节点 payloadtype— 节点 type hashtimestamp— 节点时间戳4.4 Render 流程整合
ucas render <hash>时按 node type 查找@ucas/template/text/<type>4.5 Decay 优先级链
decay: 0.7> CLI--decay> 引擎默认0.5验证
依赖
Phase 2(模板注册)+ Phase 3(render 核心)
Refs #36
小橘 🍊(NEKO Team)
🔍 Post-Merge Review: PR #45 — LiquidJS Template Rendering Integration
Summary
PR #45 merged 3 commits adding LiquidJS template rendering to json-cas. Files changed:
liquid-render.ts,liquid-render.test.ts,render.ts,index.ts(json-cas),index.ts,cli.test.ts(cli-json-cas),package.json,bun.lock.✅ What's Good
liquid-render.ts(293 lines) is well-structured with clear separation — engine creation, node rendering, template discovery, and fallback rendering{% render %}tag properly implements variable resolution with dot-path support and explicit decay syntax ({% render payload.child, decay: 0.7 %})@ucas/template/text/<type-hash>variable convention works cleanly throughVariableStorerenderAsync()inrender.tselegantly bridges sync YAML rendering with async template rendering, with proper fallbackliquidjsis statically imported ✅anyusage, properimport typefor type-only imports,.jsextensions in import paths ✅biome check .clean ✅tsc --buildclean ✅ucas rendernow passesvarStoretorenderAsync()for template-aware rendering. 5 CLI integration tests (Suite 6) covering default params, custom decay, all params, YAML fallback, and error handling⚠️ Minor Observations
Duplicate
RenderOptionstype: Bothliquid-render.tsandrender.tsdefineRenderOptions. The one inrender.tshas an extravarStore?field. Onlyrender.ts's version is exported. Consider havingliquid-render.tsimport fromrender.tsor extract to a shared types file to avoid drift._globalDecayunused parameter: InrenderNode()(liquid-render.ts:170),_globalDecayis passed through but never used — theengineclosure already capturesglobalDecay. The underscore prefix correctly signals intent but the parameter could be removed.enginevariable in render tag: The custom render tag'srender()method (line 143) referencesenginefrom the outercreateLiquidEngineclosure — this works but creates a tight coupling. Acceptable for now.Test file uses
await import("liquidjs"): Tests 1.1–1.3 use dynamic imports for basic LiquidJS verification. Not a project rule violation (rule applies to source, not tests), but static imports would be more consistent.CLI test failures are pre-existing: 25 CLI test failures exist but are unrelated to this PR (they fail on
runCliAliaswhich usesbun run— likely a path/environment issue).Missing test suites 4.2, 4.3, 7.3, 9.x: Test numbering has gaps (e.g., Suite 4 jumps from 4.1 to 4.4). Not a bug, but suggests some planned tests were deferred.
📊 Verdict
Solid merge. Clean code, thorough tests, follows all CLAUDE.md conventions. The duplicate
RenderOptionstype is the only thing worth addressing in a follow-up.小橘 🍊(NEKO Team)