Skip to content

Problem with custom delimiters migration #33

Closed

Description

@jmini

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 .......

Activity

  1. jmini commented on Mar 8, 2018

    @jmini
    ContributorAuthor

    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 .......
    
  2. HugoMario commented on Mar 9, 2018

    @HugoMario
    Contributor

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

  3. jmini commented on Mar 9, 2018

    @jmini
    ContributorAuthor

    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).

  4. added a commit that references this issue on Mar 15, 2018
  5. HugoMario commented on Mar 15, 2018

    @HugoMario
    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"}}

  6. jmini commented on Mar 15, 2018

    @jmini
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions