Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with mustache syntax #662

Closed
marcotrumpet opened this issue Dec 11, 2022 · 2 comments
Closed

fix: issue with mustache syntax #662

marcotrumpet opened this issue Dec 11, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@marcotrumpet
Copy link

Description

Based on an array, try looping in it to generate one file per item in the array and access the item value in the corresponding file.
NOTE -> this issue happens only when the code is poorly written but I needed a couple of tries to figure it out (if the dart code is correct there are no issues).

Steps To Reproduce

  1. Go to this gist https://gist.github.com/marcotrumpet/1e4b4c421529adbd8cc1681424d4f65c
  2. Copy the pre_gen code into hook
  3. Create a fine into brick with following path {{#arrayValues}}{{{valueName}}}_name_checker.dart{{/arrayValues}}
  4. Copy in it the name_checker.dart file content
  5. run mason make

Expected Behavior

No specific expected behavior. Don't know if it's possible to evaluate {{arrayValues.valueName}} besides the wrong dart code or if an error can be thrown in the cli.

Screenshots
As you can see the generated file doesn't evaluate {{arrayValues.valueName}}
Screenshot 2022-12-11 alle 17 32 47

@marcotrumpet marcotrumpet added the bug Something isn't working label Dec 11, 2022
@felangel
Copy link
Owner

felangel commented Dec 18, 2022

Hi @marcotrumpet 👋
Thanks for opening an issue!

I believe the issue is due to the fact that this expression is not interpreted as valid due to the imbalanced brackets. I think you should be able to rewrite it as:

void main() {
  final String testString = '${{#mustacheCase}}{{arrayValues.valueName}}.capitalize(){{/mustacheCase}};
}

Let me know if that helps 👍

@marcotrumpet
Copy link
Author

Yeah for sure first of all the code example is wrong. This helps for sure. The thing that puzzles me is that if you have more than one call to {{arrayValues.valueName}} if one is broken then all of them are. I think it definitely has something to do with the render method from mustache_template but not sure.
By the way, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants