From 7456e1578a903feb40349d9ac4e2a2831c54dbe1 Mon Sep 17 00:00:00 2001 From: Hugo Mercado Date: Wed, 14 Mar 2018 21:22:06 -0500 Subject: [PATCH] Issue #33: added braces helper. --- .../handlebars/helpers/BracesHelper.java | 22 +++++++++++++++++++ .../languages/DefaultCodegenConfig.java | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/io/swagger/codegen/handlebars/helpers/BracesHelper.java diff --git a/src/main/java/io/swagger/codegen/handlebars/helpers/BracesHelper.java b/src/main/java/io/swagger/codegen/handlebars/helpers/BracesHelper.java new file mode 100644 index 0000000000..3e59d98b64 --- /dev/null +++ b/src/main/java/io/swagger/codegen/handlebars/helpers/BracesHelper.java @@ -0,0 +1,22 @@ +package io.swagger.codegen.handlebars.helpers; + +import com.github.jknack.handlebars.Helper; +import com.github.jknack.handlebars.Options; + +public class BracesHelper implements Helper { + + public static final String NAME = "braces"; + private static final String RIGHTT_ORIENTATION = "right"; + private static final String LEFT_CURLY_BRACES = "{{"; + private static final String RIGHT_CURLY_BRACES = "}}"; + + @Override + public Object apply(String orientation, Options options) { + if (RIGHTT_ORIENTATION.equalsIgnoreCase(orientation)) { + return RIGHT_CURLY_BRACES; + } + return LEFT_CURLY_BRACES; + } + + +} diff --git a/src/main/java/io/swagger/codegen/languages/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/languages/DefaultCodegenConfig.java index d9c64dc69c..23b7c56488 100644 --- a/src/main/java/io/swagger/codegen/languages/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/languages/DefaultCodegenConfig.java @@ -15,6 +15,7 @@ import io.swagger.codegen.CodegenResponse; import io.swagger.codegen.CodegenSecurity; import io.swagger.codegen.SupportingFile; +import io.swagger.codegen.handlebars.helpers.BracesHelper; import io.swagger.codegen.handlebars.helpers.HasHelper; import io.swagger.codegen.handlebars.helpers.HasNotHelper; import io.swagger.codegen.handlebars.helpers.IsHelper; @@ -3257,6 +3258,7 @@ public void addHandlebarHelpers(Handlebars handlebars) { handlebars.registerHelper(HasHelper.NAME, new HasHelper()); handlebars.registerHelper(IsNotHelper.NAME, new IsNotHelper()); handlebars.registerHelper(HasNotHelper.NAME, new HasNotHelper()); + handlebars.registerHelper(BracesHelper.NAME, new BracesHelper()); } @Override