Skip to content

docs: lead README and pubspec with chat template rendering - #23

Merged
leehack merged 1 commit into
mainfrom
docs/pub-dev-discoverability
Sep 25, 2026
Merged

leehack merged 1 commit into
mainfrom
docs/pub-dev-discoverability

Conversation

@leehack

@leehack leehack commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Puts chat template rendering first on pub.dev: README, Example tab, pubspec description and topics. Docs and metadata only; no behavior change.

What changed

  • README: one-line pitch, dart pub add dinja, and a runnable Qwen2.5-style example with a system message, a user turn, a tool and add_generation_prompt. Then Why dinja, input marking, template analysis, a comparison with package:jinja, and scope. Removed the false "zero-dependency" claim and the ^1.1.0 pin.
  • Example tab: example/chat_template_example.dart is now the README example, and example/README.md shows it inline with its output.
  • pubspec: new description and topics; removed the stray # path comment. The lib/dinja.dart library doc also dropped "zero-dependency".
Before After
Description A minimal, zero-dependency Jinja templating engine for Dart, ported from llama.cpp. Focused on security and efficiency. Jinja engine for Hugging Face and GGUF LLM chat templates: messages, tools, generation prompts. Parity-tested against llama.cpp and Jinja2. All platforms, including web and Wasm. (178 chars)
Topics jinja2, template, llm, security, chat-templates jinja, template, llm, chat-templates, huggingface

Topics: pub.dev's doc/topics.yaml has no alias for any of them, so jinja2 is not merged into jinja. topic:jinja already lists jinja_minimal, and topic:jinja2 listed only dinja. security (100+ packages) and ai (100+) are too broad, and prompt is used by terminal-prompt packages. pub.dev's text search indexes only the description, the README and API symbols (mem_index.dart), not topics. So the description keeps Jinja2, and the README keeps prompt, template and a huggingface token (huggingface.co).

How each claim was verified

  • 290 cases, 279 pass, 11 skipped: regenerating test/llama_cross_test.dart from llama.cpp 7fe450e1 tests/test-jinja.cpp gives no diff, and dart test test/llama_cross_test.dart reports +279 ~11. llama.cpp's own test-jinja at 7fe450e1 skips the same 11 as NotImplemented.
  • Expected outputs match Jinja2 3.1.6: test-jinja -py with Jinja2 3.1.6 passes 290/290 with 0 failures.
  • 45 real templates: test/fixtures/templates has 50 files with 45 distinct contents. Instrumenting Template.render and running test/templates showed that all 45 are rendered.
  • README example output is the same in dinja, llama.cpp and Jinja2: the same template and variables go through test-jinja at 7fe450e1 (0 failures) and through Jinja2 3.1.6 in llama.cpp's transformers-style sandbox (match).
  • Every README and example snippet is extracted, formatted, analyzed and run, and its stdout matches the output block that follows it exactly.
  • llama-server uses common/jinja: tools/server calls common_chat_templates_apply, and common/chat.cpp runs jinja::runtime.
  • Web and Wasm: dart test -p chrome and dart test -p chrome -c dart2wasm on test/src and test/llama_cross_test.dart both report +790 ~11. pana tags all six platforms and is:wasm-ready.
  • Used by llamadart: llamadart 0.8.24 on pub.dev depends on dinja and imports it in chat_template_handler.dart.
  • Unsupported tags and format: extends, block, include, import, raw and with each throw ParserException, and '%s'|format(1) renders %s.
  • package:jinja: the wording comes from its README ("server-side template engine … template inheritance").

Gates

dart format clean · dart analyze no issues · dart test +892 ~11 · dart pub publish --dry-run 0 warnings · pana 160/160.

@leehack
leehack merged commit 74d487e into main Sep 25, 2026
1 check passed
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