Conversation
|
Could you explain, give an use example? If I understand correctly, for internationalisation, couldn't you just pass an object with a different set of strings? |
|
This isnt just targeted at internationalization is it? As it enables extensibility it resembles a simple plugin system IMO. Could it be something to work on related to plugins / pragmas as mentioned in #406? |
|
@dasilvacontin var translationsHash = {
firstName: "First name",
lastName: "Last name"
};
Mustache.addCustomTag('i', function(contents, value) {
return translationsHash[contents];
});Template may look like this: <div class="user">
<div class="user-firstName">{{i lastName}}: {{firstName}}</div>
<div class="user-lastName">{{i firstName}}: {{lastName}}</div>
</div>If we use this approach, we don't need to pass strings at all. @phillipj |
|
@zverev, thanks for the template example. Couldn't you just pass a different data/model object or a modified one to |
|
@dasilvacontin |
|
No worries. I see what you mean. We certainly need some kind of Plugin API. Having a Plugin API would make solving this issue something trivial. I think we should discuss how we approach adding a Plugin API in a separate issue. |
Hello,
I've tried to make an internationalization for our project using mustache, but didn't find a rather simple way to do it. So i've thought about using custom tag for this task. For example
{{i some text}}.Does this idea corresponds to the philosophy of mustache.js?
Best regards,
Alexander