casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
748 stars 56 forks source link

KTE: Generate templates using default parameter values #285

Closed marcospereira closed 10 months ago

marcospereira commented 11 months ago

What?

Kotlin supports default parameters at method definition. For example:

fun hello(name: String = "jte"): JteModel

But those are not used when generating code. This adds the default values, except for gg.jte.Content since the syntax (code>@``</code) is not supported in Kotlin Code. This will allow users to call templates from Kotlin code without the need to pass the already defined (at the templates) default values.

Currently, only calls from another template recognize the default values.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (05f6aee) 91.13% compared to head (0c44ad7) 91.22%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #285 +/- ## ============================================ + Coverage 91.13% 91.22% +0.08% - Complexity 1186 1193 +7 ============================================ Files 76 76 Lines 3113 3121 +8 Branches 480 482 +2 ============================================ + Hits 2837 2847 +10 + Misses 168 167 -1 + Partials 108 107 -1 ``` | [Files](https://app.codecov.io/gh/casid/jte/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Hager) | Coverage Δ | | |---|---|---| | [...va/gg/jte/compiler/kotlin/KotlinCodeGenerator.java](https://app.codecov.io/gh/casid/jte/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Hager#diff-anRlLWtvdGxpbi9zcmMvbWFpbi9qYXZhL2dnL2p0ZS9jb21waWxlci9rb3RsaW4vS290bGluQ29kZUdlbmVyYXRvci5qYXZh) | `97.17% <100.00%> (+0.01%)` | :arrow_up: | | [...n/java/gg/jte/compiler/kotlin/KotlinParamInfo.java](https://app.codecov.io/gh/casid/jte/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Hager#diff-anRlLWtvdGxpbi9zcmMvbWFpbi9qYXZhL2dnL2p0ZS9jb21waWxlci9rb3RsaW4vS290bGluUGFyYW1JbmZvLmphdmE=) | `91.11% <100.00%> (ø)` | | | [...ls/src/main/java/gg/jte/models/generator/Util.java](https://app.codecov.io/gh/casid/jte/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Hager#diff-anRlLW1vZGVscy9zcmMvbWFpbi9qYXZhL2dnL2p0ZS9tb2RlbHMvZ2VuZXJhdG9yL1V0aWwuamF2YQ==) | `77.77% <100.00%> (+15.87%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

marcospereira commented 10 months ago

Thanks, @casid!

I've rebased against the main branch, and this should be good to go. :-)

casid commented 10 months ago

Yes! Thank you for the contribution, merged and closed!

marcospereira commented 10 months ago

Yes! Thank you for the contribution, merged and closed!

Thank you. Contributing to the project has been a great experience. :-)

Do you have an idea of when a new release will be made?

casid commented 10 months ago

I could do one this week for sure!