i18n-node icon indicating copy to clipboard operation
i18n-node copied to clipboard

how to do variable replacement in mustache template with express?

Open stanleyfok opened this issue 10 years ago • 3 comments

how to do variable replacement in mustache template with express?

stanleyfok avatar Apr 10 '15 04:04 stanleyfok

maybe you could outline your use case a bit more?

mashpie avatar Jan 31 '16 20:01 mashpie

Hello, Is there any relationship with this ticket? https://github.com/codeva/hapi-i18n/issues/7

odorisioe avatar Sep 15 '16 21:09 odorisioe

probably... thing is that some template engines handle parameter passing differently:

<%= __('Hello') %>
${__('Hello')}
<%= __('Hello {{name}}', { name: 'Marcus' }) %>
${__('Hello {{name}}', { name: 'Marcus' })}

from handlebars docs http://handlebarsjs.com/expressions.html

Handlebars helpers can also receive an optional sequence of key-value pairs as their final parameter (referred to as hash arguments in the documentation):

{{{link "See more..." href=story.url class="story"}}}

one should be able to setup a helper handling stuff like this:

{{{__ 'Hello {{name}}' name='Marcus'}}}

but this is just guess and probably needs some work to implement by yourself (see https://github.com/mashpie/i18n-node#attaching-helpers-for-template-engines)

I'll check to find some reasonable default implementation + example as soon I find time to

mashpie avatar Sep 16 '16 12:09 mashpie