|
|
@@ -223,6 +223,20 @@ translation _before_ any rendering is done. For example: |
|
|
alert(Mustache.to_html(template, view)); |
|
|
alert(Mustache.to_html(template, view)); |
|
|
// alerts "Mae Matt yn defnyddio mustache.js!" |
|
|
// alerts "Mae Matt yn defnyddio mustache.js!" |
|
|
|
|
|
|
|
|
|
|
|
### The TRANSLATION-HINT Pragma |
|
|
|
|
|
|
|
|
|
|
|
Some single words in English have different translations based on usage context. Mustache.js supports this with the TRANSLATION-HINT pragma. For example, the word "Tweet" can be used as a noun, or a verb. The following template is ambiguous: |
|
|
|
|
|
|
|
|
|
|
|
<div class="tweet-button">{{_i}}Tweet{{/i}}</div> |
|
|
|
|
|
|
|
|
|
|
|
By adding a pragma, we can provide the right context for a given template: |
|
|
|
|
|
|
|
|
|
|
|
{{%TRANSLATION-HINT mode=tweet_button}} |
|
|
|
|
|
|
|
|
|
|
|
<div class="tweet-button">{{_i}}Tweet{{/i}}</div> |
|
|
|
|
|
|
|
|
|
|
|
This will lookup every translation in that template with the mode, e.g. `_('Tweet', {_mode: "tweet_button"})`, which your gettext implementation can handle as appropriate. |
|
|
|
|
|
|
|
|
## Escaping |
|
|
## Escaping |
|
|
|
|
|
|
|
|
mustache.js does escape all values when using the standard double mustache |
|
|
mustache.js does escape all values when using the standard double mustache |
|
|
@@ -279,6 +293,10 @@ own iteration marker: |
|
|
{{bob}} |
|
|
{{bob}} |
|
|
{{/foo}} |
|
|
{{/foo}} |
|
|
|
|
|
|
|
|
|
|
|
### TRANSLATION-HINT |
|
|
|
|
|
|
|
|
|
|
|
See the "Internationalization" section above for info on this pragma. |
|
|
|
|
|
|
|
|
## F.A.Q. |
|
|
## F.A.Q. |
|
|
|
|
|
|
|
|
### Why doesn’t Mustache allow dot notation like `{{variable.member}}`? |
|
|
### Why doesn’t Mustache allow dot notation like `{{variable.member}}`? |
|
|
|