Skip to content

[mustache_template] add example app and migrate README to excerpts#11333

Open
mozammal-hossain wants to merge 11 commits intoflutter:mainfrom
mozammal-hossain:fix/add-example-mustache-template
Open

[mustache_template] add example app and migrate README to excerpts#11333
mozammal-hossain wants to merge 11 commits intoflutter:mainfrom
mozammal-hossain:fix/add-example-mustache-template

Conversation

@mozammal-hossain
Copy link
Copy Markdown

@mozammal-hossain mozammal-hossain commented Mar 23, 2026

This PR adds a runnable example/ app for mustache_template and migrates README usage snippets to excerpt-managed code from that example. This addresses the missing example app noted in the issue and aligns the package with the repository’s code-excerpt documentation pattern.

It also removes mustache_template from script/configs/temp_exclude_excerpt.yaml now that excerpt support is in place, and includes the corresponding version/CHANGELOG updates.

Fixes flutter/flutter#183936

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard
Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 23, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the mustache_template package to version 2.0.4, introducing an example/ app to provide code snippets for the README.md via code-excerpt directives. The review notes that some nuanced lambda examples and documentation for LambdaContext.renderSource were removed from the README, and there's a syntax error in the docregion tags in example/main.dart that needs to be fixed.

Updated the example in main.dart to fix the doc region tags for nested paths, ensuring proper documentation generation. This change enhances clarity and maintains consistency in the example code.
@mozammal-hossain
Copy link
Copy Markdown
Author

Hi @ianloic, @precision, @sethladd, @romeo4934 — this PR is a docs/example update for mustache_template (restores nuanced lambda examples and LambdaContext.renderSource performance guidance), with no production/runtime behavior changes.

Could someone please:

  • approve the pending workflow run, and
  • provide the required review approval (if the content looks good)?

I also see tree-status is currently red; I’ll wait for tree reopen/normal merge guidance if needed.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

@mozammal-hossain Do not ping random people in PRs.

You checked the box indicating that you read the contributing guidelines, which means you will have seen the multiple places where we say that reviews can take up to two weeks. Pinging people (especially the wrong people) almost immediately after opening the PR does not respect people's time, or our process.

@stuartmorgan-g stuartmorgan-g changed the title mustache_template: add example app and migrate README to excerpts [mustache_template] add example app and migrate README to excerpts Mar 23, 2026
Copy link
Copy Markdown
Contributor

@bkonyi bkonyi left a comment

Choose a reason for hiding this comment

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

LGTM overall with one question.


import 'package:mustache_template/mustache_template.dart';

// #docregion BasicRender
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.

What's with these #docregion comments?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's how our code excerpt system works.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

docregion = document region.

That means - same code has been written on the documentation(package's README.md).

Copy link
Copy Markdown
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

No new package logic was introduced; this change adds documentation/example structure and excerpt wiring, so no additional tests were added

There is a lot of new code, in example/lib/main.dart. There's no reason it can be exercised in a test that ensures that the snippets are actually showing working (not just compiling) code.

See an earlier attempt at this issue for examples of what tests might look like.

print(output);
}
```
Templates are parsed when created and can be rendered repeatedly with different
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's a lot of re-wrapping and re-wording of the README, which makes the diffs really hard to review. Please undo the README changes that aren't related to adopting snippets. If you believe the README needs rewriting, please file an issue describing why, and make a follow-up PR addressing it, so that we can evaluate those changes in isolation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've undo the README.md. (replace the README by This: LINK )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That is not what I requested, and doing this put the PR into a clearly inconsistent state.

You checked the box for the AI contribution guidelines in the PR template; were the changes to adopt excerpts that you originally posted authored by you, or were they AI generated changes that you read and understood before posting the PR?

Copy link
Copy Markdown
Author

@mozammal-hossain mozammal-hossain Mar 29, 2026

Choose a reason for hiding this comment

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

As you've asked me to create another issue for updating the README, I didn't create any. But replaced the README as per your suggestion. I thought, After merging the PR, issue will be created.

Or am i misunderstanding your suggestions?
N:B: AI can't give PR. I'm doing these by myself following your suggestions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As you've asked me to create another issue for updating the READM

I asked you to create another issue if you want to make a bunch of unrelated edits to the text of the README (like changing "A template is parsed when it is created" to "Templates are parsed when created" on the line the initial comment was attached to).

But replaced the README as per your suggestion.

I did not suggest replacing the README. I asked you to undo the changes to the README that were not related to adopting code excerpts.

Do you believe that the current version of the PR is adopting code excerpts?

N:B: AI can't give PR.

It can actually, but that's not what I asked. I asked whether you used AI to generate the changes that you included in the initial PR. Given that the PR description reads like it was generated with AI, and that completely reverting the README doesn't make sense in the context of the rest of the PR, I am trying to understand to what extent you may have used AI for the coding, as that might explain the disconnect here.

Copy link
Copy Markdown
Author

@mozammal-hossain mozammal-hossain Mar 30, 2026

Choose a reason for hiding this comment

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

I did not suggest replacing the README. I asked you to undo the changes to the README that were not related to adopting code excerpts.

Again, I didn't know, a single file can be modify/update from any commit. So, i was trying to replacing readme . Now I have undo all the changes and started updating README.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Do you believe that the current version of the PR is adopting code excerpts?

No, README should be updated. otherwise, script run will not work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Given that the PR description reads like it was generated with AI

Yes, It was generated with AI and I did few changes to match up with the coding style/PR rules.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

N:B: AI can't give PR

Apologies for this comment. Yes, Claude, Github co-pilot can create PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've updated the example like readme's example. (These are showing warning, suggesting to make those from var to final).

But as i've added two new example for "Strict Mode" and "Lenient Mode". So updated on the readMe for this. (Used final here)

```dart
var t = Template('{{ author.name }}');
var output = template.renderString({'author': {'name': 'Greg Lowe'}});
void showStrictVsLenientBehavior() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You've made all of the examples much longer without adding any substance, by including things like the print and the surrounding method definition. The excerpts should have the same scope they did before.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I’ve trimmed the README excerpts back to the minimal snippets

Copy link
Copy Markdown
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

(Fixing review state; that was meant to be a "Request changes".)

…erpts and unit tests

- Added an `example/` app with runnable usage samples.
- Updated README examples to reference new excerpt-managed snippets.
- Introduced unit tests for README code excerpts.
- Moved excerpt sources to `example/lib/readme_excerpts.dart`.
- Fixed a lambda example in the README to correct an invalid tag.
@mozammal-hossain
Copy link
Copy Markdown
Author

No new package logic was introduced; this change adds documentation/example structure and excerpt wiring, so no additional tests were added

There is a lot of new code, in example/lib/main.dart. There's no reason it can be exercised in a test that ensures that the snippets are actually showing working (not just compiling) code.

See an earlier attempt at this issue for examples of what tests might look like.

I've added Test cases.

@mozammal-hossain
Copy link
Copy Markdown
Author

(Fixing review state; that was meant to be a "Request changes".)

I've updated everything as per your suggestions. 😊

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.

This file should probably be under example/bin/main.dart.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It wouldn't show up on pub if we do that (see https://dart.dev/tools/pub/package-layout#examples). If we want a bin entrypoint it would need to be a thin wrapper around lib/main.dart.

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.

TIL!

…odes

- Enhanced README.md with examples demonstrating strict and lenient rendering modes.
- Updated example Dart files to reflect new function names for strict and lenient mode behaviors.
- Refactored code in example files to use `var` instead of `final` for variable declarations for consistency.
- Improved test cases to validate strict and lenient mode behaviors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mustache_template] No example app

3 participants