문제

I am evaluating different template engines for i18n purposes and I wonder if it is possible to create nested helpers in dust.js in order to user both i18n and pluralization (or simply variables) for a single sentence.

Consider the following example from PHP/WordPress, which uses gettext along with printf:

<?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', $comment_count ), $comment_count, $post_title ); ?>

Here we have _n() wrapped inside of printf(). Is this possible with dust.js helpers?

도움이 되었습니까?

해결책

Nested helpers are definitely possible within Dust.js, as long as the nested helper is in the body of the outer helper (as opposed to being within the parameters). The @select helper is an example of nested helpers already in wide use.

{@select key=myKey}
  {@eq value="Yes"}YES{/eq}
  {@eq value="No"}NO{/eq}
  {@default}Neither here nor there{/default}
{/select}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top