Closed siddharthvp closed 3 years ago
@santhoshtr any thoughts?
This looks like a good idea to me. Your PR make sense too. This is more or less in alignment with the extend option available in jquery.i18n(https://github.com/wikimedia/jquery.i18n#extending-the-parser).
Could you please add some test too?
Also, documentation(README.md)
Done: updated documentation (adapted from jquery-i18n documentation), added tests and typescript type.
A simple contrived example would be:
Which makes
This can be used practically for a lot of purposes, particularly for operations that require some data to be available which can be fetched from the client script. For example on mediawiki sites, a client script could add a hook for formatting dates using the month names fetched from MediaWiki API.
Let me know what you think about this. Another less explicit way of allowing these hooks would be to export the BananaEmitter class, so that clients can directly modify its prototype.