Skip to content

[mustache_template] Add example app and code excerpts#11466

Open
HibaChamkhi wants to merge 7 commits into
flutter:mainfrom
HibaChamkhi:mustache-template-example-app
Open

[mustache_template] Add example app and code excerpts#11466
HibaChamkhi wants to merge 7 commits into
flutter:mainfrom
HibaChamkhi:mustache-template-example-app

Conversation

@HibaChamkhi
Copy link
Copy Markdown

Adds an example app for the mustache_template package, adds code excerpts,
and removes the package from script/configs/temp_exclude_excerpt.yaml.

Fixes flutter/flutter#183936

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 introduces a Flutter example application for the mustache_template package and refactors the README.md to utilize code excerpts from the new example. Additionally, the package is removed from the excerpt exclusion list, and the version is bumped to 2.0.5. Feedback suggests making the changelog entry more descriptive regarding the specific features demonstrated by the example app.

@@ -1,3 +1,8 @@
## 2.0.5

* Adds example app.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The changelog entry for the example app is redundant with the description of the change. Consider being more specific about what the example app demonstrates.

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.

Thanks for the contribution!

Please look over the review feedback on the previous attempted PRs that referenced this issue, and make sure that your PR addresses all of that feedback. For instance, this PR significantly rewrites the README in ways that have nothing to do with the issue, which as discussed previously is not in scope for this PR, and this also doesn't have meaningful tests, as was flagged in several previous PRs.

Also, as this package does not have a Flutter dependency, the example app should be a Dart script, not a Flutter app.

@HibaChamkhi
Copy link
Copy Markdown
Author

Thanks for the feedback! I've addressed the review comments:

  • Converted the example from a Flutter app to a Dart script
  • Restored the README to its original content, only adding code-excerpt references

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Apr 17, 2026
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.

and this also doesn't have meaningful tests, as was flagged in several previous PRs

This has not been addressed in the PR update; there is still nothing ensuring that the excerpts run as expected.

var t = Template('{{# foo }}{{bar}}{{/ foo }}');
var lambda = (LambdaContext ctx) => '<b>${ctx.renderString().toUpperCase()}</b>';
t.renderString({'foo': lambda, 'bar': 'pub'}); // <b>PUB</b>
```
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.

Why are these examples removed?

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.

@stuartmorgan-g Both issues fixed:

  1. Lambda examples restored in README (both renderString and renderSource examples with var syntax)
  2. Added test/example_test.dart with 5 tests ensuring all README excerpts run correctly

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.

with var syntax

Code excerpts need to follow our style. The source file should not be overriding any style rules other than avoid_print.

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.

@stuartmorgan-g fixed:

1- Lambda examples restored in README
2- Added test/example_test.dart
3- Following style guidelines (only ignoring avoid_print)

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.

This comment says you have restored them, but they are still missing in the diff you have posted.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 21, 2026
- Use final instead of var in example code
- Add proper type annotations (Object) for non-obvious types
- Only ignore avoid_print lint rule as required
- Update README excerpts to reflect proper style

print(output);
}
void main() {
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.

We don't want unbalanced code in examples; this isn't ever closed.

Since being part of main isn't relevant to the example, this line should just be removed from the snippet context.

],
});

print(output);
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.

This should also not be part of the snippet context since it doesn't add anything useful. (The old example was a complete mini-program, but that's not actually something we want to keep.

final Object nestedOutput = t.renderString({
'author': {'name': 'Greg Lowe'},
});
print(nestedOutput);
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 added print statements to many of the snippets; they aren't useful in showing what clients need to do, so should not be in the snippets.

var t = Template('{{# foo }}{{bar}}{{/ foo }}');
var lambda = (LambdaContext ctx) => '<b>${ctx.renderString().toUpperCase()}</b>';
t.renderString({'foo': lambda, 'bar': 'pub'}); // <b>PUB</b>
```
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.

This comment says you have restored them, but they are still missing in the diff you have posted.

var t = Template('{{# foo }}{{bar}}{{/ foo }}');
var lambda = (LambdaContext ctx) => ctx.renderSource(ctx.source + ' {{cmd}}');
t.renderString({'foo': lambda, 'bar': 'pub', 'cmd': 'build'}); // pub build
final rst = Template('{{# foo }}{{bar}}{{/ foo }}');
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.

Having different variable names for every snippet is confusing. The example should solve naming collisions by putting examples in functions, not by changing variable names each time.

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

2 participants