Skip to content

skito/ATMF-JS

Repository files navigation

ATMF-JS Tweet

Javascript support for ATMF (Advanced-Template-Markup-Format)

GitHub release (latest by date) Browser support NodeJS support ReactJS support

Cover

More about ATMF

Full specificaiton of the format is available here

Ecosystems

The ATMF engine is written in pure Javascript and it executes in all JS ecosystems. There are several libraries which wrap the core engine, in order to face enviropment specifics and get the most of ATMF. Choose your ecosystem.

Prototyping

Depending on your environment or framework you might want to have custom discovery of templates and language resources. You can prototype the ATMF engine in order to face your requiremnets.

Template Discovery

ATMFEngine.prototype.DiscoverTemplate = function (name) {
    // ...
    // Do the discovery
    // Return the template as STR or PROMISE
};

ATMFEngine.prototype.GetTemplate = function (name) {
    if (typeof this.templates[name] != 'undefined')
        return this.templates[name];
    else {
         // AS STR
         // return this.DiscoverTemplate(name);
         // OR AS PROMISE
         // this.DiscoverTemplate(name).then((name) => { });
    }
}

SetTemplateDiscoveryPath(path, ext = ['html', 'tpl']) {
    path = path.replace(/\/$/, "").replace(/\\$/, "");
    this._templateDiscoveryPath = path;
    this._templateDiscoveryExt = Array.isArray(ext) ? ext : [ext];
}

Culture Discovery

ATMFEngine.prototype.ResolveCultureResource = function (keyname) {
    var translations = {};
    
    // ...
    // Do the discovery
    // Return the translations object
    // Example
    // { 'namespace/path': { 'key1': 'value1', 'key2': 'value2' }
    
    return translations;
};