plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.12k stars 277 forks source link

Add configuration option for custom handlebar delimiters #398

Open IrrerPolterer opened 1 year ago

IrrerPolterer commented 1 year ago

Currently plop relies entirely on the default handlebar implementation with {{ and }} delimiting handlebars in template files. I want to create NextJs project generators. My nextjs template project however contains a lot of double-curly-brackets as part of the code. For example: <TestComponent property={{key1: 123, key2:456}} />

When running plop on these files, it presents error messages, because handlebarsJs tries to interpret the double-curly-brackets as handlebars but doesn't understand their content.

To eliviate this problem I would like to simply adjust the delimiters of my handlebars to something like <% and %> for example.

amwmedia commented 1 year ago

plop uses handlebars under the hood, so they would need to implement that feature first in order for us to support it. If this is already a feature of handlebars and it's somehow escaped my knowledge, please correct me. I'd love for plop to support this.

We've talked in the past about retooling plop to handle multiple templating languages, but it's been seen (so far) as not worth the effort.

There are ways of escaping double curlies for these use cases.

IrrerPolterer commented 1 year ago

Thanks for the reply, this is certainly helpful! However, excaping curly brackets doesn't seem to work properly.

This works, as described in the handlebar docs: \{{escaped}} renders {{escaped}}

But this does not work:

    {{{{raw}}}}
        {{escaped}}
    {{{{/raw}}}}

renders nothing.

amwmedia commented 1 year ago

In the case of raw block helpers, you'd need to register the helper "raw" to make that work.