javascriptopenapimustacheopenapi-generator

What is {{=< >=}} inside the mustache code of the open api generator?


In the api.mustache of the openapi-generator project is this syntax and I don't really know the meaning of the {{=< >=}} and the various kinds of html-like brackets inside the file:

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Javascript/libraries/javascript/api.mustache

{{=< >=}}
import ApiClient from "../ApiClient";
<#imports>import <&import> from '../<#modelPackage><&modelPackage>/</modelPackage><import>';
</imports>
// ...
<={{ }}=>

Could someone explain me what {{=< >=}} and <={{ }}=> is, as well as what the differences between the different kinds of brackets are?

<#imports>
<&import>
<#modelPackage>
<&modelPackage>
</modelPackage>
<import>
</imports>

What are good resources to learn all that stuff?


Solution

  • You can find more mustache syntax from here http://mustache.github.io/mustache.5.html.

    {{=< >=}} you are signifying that {{ becomes < and > can be replaces }}. so is similar to {{import}}. the ending <={{ }}=> you are resetting it back to {{ and }} syntax.

    <import> is the actual value of the import key.

    <#imports> is start of section and </imports> is end of the section if imports exists, it renders one or more times based on the number of times based on the value of the imports key. if the imports doesn't exist, the block will simply be skipped and nothing will be printed.

    same goes for all other tags.

    & represents skip htmls escape characters. import <&import> in the block first import is simple import string and <&import> will respect the character spacing defined in the template.