forked from loafle/openapi-generator-original
Adds setPrettyPrint and the reslver MethodValueResolver.INSTANCE (#10683)
This commit is contained in:
parent
f1ab3edbc0
commit
8d490835b7
@ -23,6 +23,7 @@ import com.github.jknack.handlebars.Template;
|
|||||||
import com.github.jknack.handlebars.context.FieldValueResolver;
|
import com.github.jknack.handlebars.context.FieldValueResolver;
|
||||||
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
|
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
|
||||||
import com.github.jknack.handlebars.context.MapValueResolver;
|
import com.github.jknack.handlebars.context.MapValueResolver;
|
||||||
|
import com.github.jknack.handlebars.context.MethodValueResolver;
|
||||||
import com.github.jknack.handlebars.helper.ConditionalHelpers;
|
import com.github.jknack.handlebars.helper.ConditionalHelpers;
|
||||||
import com.github.jknack.handlebars.helper.StringHelpers;
|
import com.github.jknack.handlebars.helper.StringHelpers;
|
||||||
import com.github.jknack.handlebars.io.AbstractTemplateLoader;
|
import com.github.jknack.handlebars.io.AbstractTemplateLoader;
|
||||||
@ -46,6 +47,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
|
|||||||
// We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename
|
// We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename
|
||||||
private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"};
|
private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"};
|
||||||
private boolean infiniteLoops = false;
|
private boolean infiniteLoops = false;
|
||||||
|
private boolean prettyPrint = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an identifier used to load the adapter. This could be a name, uuid, or any other string.
|
* Provides an identifier used to load the adapter. This could be a name, uuid, or any other string.
|
||||||
@ -71,7 +73,8 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
|
|||||||
.resolver(
|
.resolver(
|
||||||
MapValueResolver.INSTANCE,
|
MapValueResolver.INSTANCE,
|
||||||
JavaBeanValueResolver.INSTANCE,
|
JavaBeanValueResolver.INSTANCE,
|
||||||
FieldValueResolver.INSTANCE)
|
FieldValueResolver.INSTANCE,
|
||||||
|
MethodValueResolver.INSTANCE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Handlebars handlebars = new Handlebars(loader);
|
Handlebars handlebars = new Handlebars(loader);
|
||||||
@ -84,6 +87,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
|
|||||||
handlebars.registerHelpers(ConditionalHelpers.class);
|
handlebars.registerHelpers(ConditionalHelpers.class);
|
||||||
handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class);
|
handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class);
|
||||||
handlebars.setInfiniteLoops(infiniteLoops);
|
handlebars.setInfiniteLoops(infiniteLoops);
|
||||||
|
handlebars.setPrettyPrint(prettyPrint);
|
||||||
Template tmpl = handlebars.compile(templateFile);
|
Template tmpl = handlebars.compile(templateFile);
|
||||||
return tmpl.apply(context);
|
return tmpl.apply(context);
|
||||||
}
|
}
|
||||||
@ -134,5 +138,9 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
|
|||||||
this.infiniteLoops = infiniteLoops;
|
this.infiniteLoops = infiniteLoops;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPrettyPrint(boolean prettyPrint) {
|
||||||
|
this.prettyPrint = prettyPrint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user