胡子:如何首字母缩写

问题描述 投票:1回答:1

我正在使用胡子模板,以便使用Java生成一些代码。

我想把一个字段的第一个字母写下来。

有没有办法得到它?

我需要直接改造它。我正在生成C#代码。

编辑

我正在使用Swagger Codegen tool以便能够根据API规范生成客户端。

此工具使用胡子模板生成输出。因此,您需要的每种语言都有一个模板。请参阅here,以观看Swagger Codegen提供的小胡子模板。

我正在修改这些以便自定义我想要访问的C#代码。

{{#apiInfo}}
{{#apis}}
    this.{{classname}} = new {{apiPackage}}.{{classname}}(this.Configuration);
{{/apis}}
{{/apiInfo}}

它必须生成如下内容:

this.UserAPI = new Api.UserAPI(this.Configuration);

我想得到:

this.userAPI = new Api.UserAPI(this.Configuration);
java mustache
1个回答
1
投票

由于这个问题特定于swagger codegen工具,因此它们具有小胡子的lambda函数。

{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}

尝试:

this.{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}} = new {{apiPackage}}.{{classname}}(this.Configuration);

在模板中查找示例:https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache

© www.soinside.com 2019 - 2024. All rights reserved.