[mustache_template] Add example app and code excerpts - #23
HibaChamkhi wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds an example application demonstrating basic templates, nested paths, partials, and lambdas, updates the README to use code excerpts from this example, and adds corresponding tests. The review feedback highlights several formatting issues in the newly added example and test files where lines exceed the 80-character limit or do not conform to the Dart auto-formatter.
| final template = | ||
| Template('{{> partial-name }}', partialResolver: resolver); |
There was a problem hiding this comment.
This line is not formatted correctly according to the Dart auto-formatter. It should be on a single line since it fits within the 80-character limit.
| final template = | |
| Template('{{> partial-name }}', partialResolver: resolver); | |
| final template = Template('{{> partial-name }}', partialResolver: resolver); |
References
- Code should follow the Flutter style guide, and use the Dart auto-formatter. (link)
| final output = | ||
| template.renderString({'foo': lambda, 'bar': 'pub', 'cmd': 'build'}); |
There was a problem hiding this comment.
This line is not formatted correctly according to the Dart auto-formatter. It should be wrapped properly to adhere to the 80-character limit.
final output = template.renderString({
'foo': lambda,
'bar': 'pub',
'cmd': 'build',
});References
- Code should follow the Flutter style guide, and use the Dart auto-formatter. (link)
| final lambda = (LambdaContext ctx) => '<b>${ctx.renderString().toUpperCase()}</b>'; | ||
| final output = template.renderString({'foo': lambda, 'bar': 'pub'}); // <b>PUB</b> |
There was a problem hiding this comment.
This line exceeds the 80-character limit and is not formatted according to the Dart auto-formatter. Formatting this file is also important because the code excerpt tool will otherwise overwrite the formatted code in README.md with this unformatted version.
final lambda =
(LambdaContext ctx) => '<b>${ctx.renderString().toUpperCase()}</b>';
final output = template.renderString({
'foo': lambda,
'bar': 'pub',
}); // <b>PUB</b>References
- Code should follow the Flutter style guide, and use the Dart auto-formatter. (link)
| final lambda = (LambdaContext ctx) => ctx.renderSource(ctx.source + ' {{cmd}}'); | ||
| final output = template.renderString({'foo': lambda, 'bar': 'pub', 'cmd': 'build'}); // pub build |
There was a problem hiding this comment.
These lines exceed the 80-character limit and are not formatted according to the Dart auto-formatter. Formatting this file is also important because the code excerpt tool will otherwise overwrite the formatted code in README.md with this unformatted version.
| final lambda = (LambdaContext ctx) => ctx.renderSource(ctx.source + ' {{cmd}}'); | |
| final output = template.renderString({'foo': lambda, 'bar': 'pub', 'cmd': 'build'}); // pub build | |
| final lambda = | |
| (LambdaContext ctx) => ctx.renderSource(ctx.source + ' {{cmd}}'); | |
| final output = template.renderString({ | |
| 'foo': lambda, | |
| 'bar': 'pub', | |
| 'cmd': 'build', | |
| }); // pub build |
References
- Code should follow the Flutter style guide, and use the Dart auto-formatter. (link)
|
Thank you for your contribution! Because of the volume of PRs we receive, we require that new contributors use our checklist to guide them through critical steps in creating a Flutter PR. This PR's description is missing that checklist, so it is being marked as a Draft. Please edit the PR description to add the checklist, then ensure that you have completed all of the steps. Once you've done that, please mark the PR as ready for review. If you need help, consider asking for advice on the #hackers-new channel on Discord. |
|
Since we have not heard back here, I am going to close this PR. Thank you for contributing! |
Replaces the hand-written Dart snippets in `mustache_template`'s README
with `<?code-excerpt?>` pragmas backed by a new
`example/lib/readme_excerpts.dart`, so every snippet is validated
against compilable, analyzed source instead of free-hand text (`dart pub
global run flutter_plugin_tools update-excerpts` / `validate` both pass
clean).
This surfaced two pre-existing doc bugs:
- `Template('{{# foo }}')` in the first lambda example had no closing
tag, so it threw a parse error the moment it was actually executed.
- The two `<b>PUB</b>` lambda examples were an exact copy-pasted
duplicate; the duplicate is removed.
Also removes `ci_config.yaml`, whose only purpose was opting the package
out of excerpt validation (see #102679-style TODO in the file) — no
longer needed now that the README is excerpt-backed.
**Note on overlap:** flutter/flutter#183936 already has two other open
PRs addressing it — #23 and #36. This PR was written independently and
additionally removes the `ci_config.yaml` exemption, which neither of
those does. Happy to have maintainers close this in favor of one of
those if that's preferred; flagging here so reviewer time isn't wasted
on duplicate review.
Fixes flutter/flutter#183936
## Pre-Review Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] page, which explains my
responsibilities.
- [x] I read and followed the [Flutter style guide] and ran [the
auto-formatter].
- [x] I signed the [CLA].
- [x] The title of the PR starts with the name of the package surrounded
by square brackets, e.g. `[vector_math]`
- [x] I [linked to at least one issue that this PR fixes] in the
description above.
- [x] I followed [the version and CHANGELOG instructions], using
[semantic versioning] and the [repository CHANGELOG style], or I have
commented below to indicate which documented exception this PR falls
under[^1].
- [x] I updated/added any relevant documentation (doc comments with
`///`).
- [x] I added new tests to check the change I am making, or I have
commented below to indicate which [test exemption] this PR falls
under[^1].
- [x] All existing and new tests are passing.
This PR only touches the README, CHANGELOG, an example app, and a CI
opt-out file — no package source changed, so it falls under the
documentation/example test exemption. The new
`example/lib/readme_excerpts.dart` is exercised directly (`dart run`) as
part of verifying this change, and every existing test in the package
(`dart test`, 252 tests) still passes.
[^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.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/core-packages/blob/main/CONTRIBUTING.md
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[Flutter style guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[the auto-formatter]:
https://github.com/flutter/packages/blob/main/script/tool/README.md#format-code
[CLA]: https://cla.developers.google.com/
[linked to at least one issue that this PR fixes]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[the version and CHANGELOG instructions]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version-and-changelog-updates
[semantic versioning]:
https://dart.dev/tools/pub/versioning#semantic-versions
[repository CHANGELOG style]:
https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style
[test exemption]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
FPOCTSMP-8
Adds an example app for the mustache_template package, adds code excerpts to the README, and updates the CHANGELOG.
Fixes flutter/flutter#183936