[mustache_template] Add example app and code excerpts#11466
[mustache_template] Add example app and code excerpts#11466HibaChamkhi wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
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. | |||
stuartmorgan-g
left a comment
There was a problem hiding this comment.
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.
|
Thanks for the feedback! I've addressed the review comments:
|
stuartmorgan-g
left a comment
There was a problem hiding this comment.
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> | ||
| ``` |
There was a problem hiding this comment.
Why are these examples removed?
There was a problem hiding this comment.
@stuartmorgan-g Both issues fixed:
- Lambda examples restored in README (both renderString and renderSource examples with var syntax)
- Added test/example_test.dart with 5 tests ensuring all README excerpts run correctly
There was a problem hiding this comment.
with var syntax
Code excerpts need to follow our style. The source file should not be overriding any style rules other than avoid_print.
There was a problem hiding this comment.
@stuartmorgan-g fixed:
1- Lambda examples restored in README
2- Added test/example_test.dart
3- Following style guidelines (only ignoring avoid_print)
There was a problem hiding this comment.
This comment says you have restored them, but they are still missing in the diff you have posted.
- 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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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> | ||
| ``` |
There was a problem hiding this comment.
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 }}'); |
There was a problem hiding this comment.
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.
Adds an example app for the
mustache_templatepackage, adds code excerpts,and removes the package from
script/configs/temp_exclude_excerpt.yaml.Fixes flutter/flutter#183936