Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Problem with custom delimiters migration #33

Closed
jmini opened this issue Mar 8, 2018 · 6 comments
Closed

Problem with custom delimiters migration #33

jmini opened this issue Mar 8, 2018 · 6 comments
Assignees

Comments

@jmini
Copy link
Contributor

jmini commented Mar 8, 2018

In Mustache, it was possible to set custom delimiters. Example (source):

{{ default_tags }}
{{=<% %>=}}
<% erb_style_tags %>
<%={{ }}=%>
{{ default_tags_again }}

Explanation:

  • On the first and last line the default delimiters {{ and }} are used.
  • Line 2 indicates that <% and %> should be used instead of {{ and }}.
  • Line 3 uses the custom delimiters
  • Line 4 indicates that {{ and }} should be set instead of <% and %>.

This do not seems to work with handlebars. This stackoverflow question propose an alternative to escape { and } in handlebar: {{"{"}} and {{"}"}}.

Example in swagger templates (example from /modules/swagger-codegen/src/main/htmlDocs2/sample_js.mustache).

Mustache:

...some text.. {{=< >=}}{<&dataType>}<={{ }}=> .. and more .......

But this does'nt work with handlebar java:

...some text.. {{"{"}}{{&dataType}}{{"}"}} .. and more .......
@jmini
Copy link
Contributor Author

jmini commented Mar 8, 2018

@jmini
Copy link
Contributor Author

jmini commented Mar 8, 2018

I do not know how handlebars works, but maybe it is possible to use a constant referenced somewhere:

...some text.. {{LEFT_CURLY_BRACKET}}{{&dataType}}{{RIGHT_CURLY_BRACKET}} .. and more .......

@HugoMario
Copy link
Contributor

we can also add a new helper class to that and dealing the issue from java code. wdyt @jmini ?

@jmini
Copy link
Contributor Author

jmini commented Mar 9, 2018

I am fine with any solution. I do not know mustache or handlebars well enough in order to have a meaningfull opinion.

I would apreciate if you could prepare the necessary infrastrure (or provide a detailed explanation on how helper class works).

@HugoMario
Copy link
Contributor

@jmini i added a new helper to address this, can you please check if it works as expected?

in your last example you just need to use:
{{braces "left"}}{{&dataType}}{{braces "right"}}

@jmini
Copy link
Contributor Author

jmini commented Mar 15, 2018

This works as expected! Thank you.

I could migrate the html2 Codegen using this construct (see #41).

Wiki page will be updated with the solution.

@jmini jmini closed this as completed Mar 15, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants