For example if I have got this line in my template
public class {{.Name}}Validator : AbstractValidator<{{.Name}}Input>
is converted to this in my output file
public class GetLoginMarketColorSettingByLoginIDValidator :
AbstractValidator< GetLoginMarketColorSettingByLoginIDInput >
Another line when I have got problems :
RuleFor(x => x.{{.Name}}).Cascade(CascadeMode.StopOnFirstFailure){{.ValidationString}};
And ValidationString is build in my code and should be (.NotEmpty().Length(1,15).WithMessage("Not a Valid LoginID");)
But the generated code for this line is
RuleFor(x =>
x.LoginID).Cascade(CascadeMode.StopOnFirstFailure).NotEmpty().Length(1,15).WithMessage("Not
a Valid LoginID");
It seems that the template system apply url encoding or it gets confused when a special character is near substitution tag ({{}})
Any hint to solve this problem ?
TIA,
Yamil
On Fri, Jun 14, 2019 at 4:09 PM Yamil Bracho <yamil...@gmail.com> wrote:
>
> I am building a kind of code generator based in golang templates and I have problems with some characters.
>
> For example if I have got this line in my template
> public class {{.Name}}Validator : AbstractValidator<{{.Name}}Input>
Are you using html/template by any chance?
If so, try text/template instead.
>
>
> is converted to this in my output file
> public class GetLoginMarketColorSettingByLoginIDValidator : AbstractValidator< GetLoginMarketColorSettingByLoginIDInput >
>
>
> Another line when I have got problems :
> RuleFor(x => x.{{.Name}}).Cascade(CascadeMode.StopOnFirstFailure){{.ValidationString}};
>
>
> And ValidationString is build in my code and should be (.NotEmpty().Length(1,15).WithMessage("Not a Valid LoginID");)
>
>
> But the generated code for this line is
> RuleFor(x => x.LoginID).Cascade(CascadeMode.StopOnFirstFailure).NotEmpty().Length(1,15).WithMessage("Not a Valid LoginID");
>
>
> It seems that the template system apply url encoding or it gets confused when a special character is near substitution tag ({{}})
>
>
> Any hint to solve this problem ?
>
>
> TIA,
> Yamil
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
Yes, I am using text/template...
El viernes, 14 de junio de 2019, 19:07:24 (UTC-4), Burak Serdar escribió:
Are you using html/template by any chance?
If so, try text/template instead.