- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 117
 
Template parameters can be deprecated #273
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
base: main
Are you sure you want to change the base?
Conversation
| 
           One more thing: Still this would maybe not work 100% all of the time, because Java users would have to pass a   | 
    
| 
           More notes: 
 Adding  However we must take care now what happens with the   | 
    

Right now it's not possible to deprecate the generated
render,applyandfmethods. So we have no choice of breaking the API as soon the args passed via@(...)change. This bit as before and bites us again in playframework/playframework#9447.Therefore I propose to once and for all fix this problem by adding a
@deprecatedParamstag, which you can use to overload therenderandapplymethod with deprecated ones. There is just one small problem: We can not overload thefmethod, because they just differ in the return type... Therefore to make this work, we need to rename thatfmethod. Therefore I will add a@templateFunctionName("...")tag which just sets the name of thefmethod.And this is how I suggest it will look like. Given you have the following template:
And you want to deprecate the arguments and replace them with String equivalents:
@********************* * This is a comment * *********************@ @import com.typsafe.... @this() @templateFunctionName("fn") @deprecatedParams("2.8.0", "f")(one: Int, two: Int) = @{ val newOne = one + 1 val newTwo = two - 1 apply(newOne.toString, newTwo.toString) } @(one: String, two: String) ...Template content here...We pass the
@deprecatedParamsthe version since when we want the methods to be deprecate and the name of theffunction which should be deprecated (here it'sfbecause that is the default name). (the generated annotation will be like@deprecated(since="2.8.0", message="Use new method fn instead")for thefmethod and@deprecated(since="2.8.0", message="""Use arguments (one: String, two: String) instead""")forapplyandrender). Finally we pass the arguments for the deprecatedrender,applyand return type off.Now in the next version we can just remove the
@deprecatedParamstag, but keep the@templateFunctionName(because that's the method's name now):@********************* * This is a comment * *********************@ @import com.typsafe.... @this() @templateFunctionName("fn") @(one: String, two: String) ...Template content here...Now in case we want to again deprecate these arguments you can now just remove the
@templateFunctionName(resulting in the generating the methodfwith its default name), but tell@deprecatedParams("2.10.0", "fn")(...that the method to deprecate isfn.TODO's:
@templateFunctionName("...")@templateFunctionName@deprecatedParams@deprecatedParams(Docs need to be added to Java and Scala API always)