{"id":22809167,"url":"https://github.com/skito/atmf-js","last_synced_at":"2025-10-30T13:06:46.032Z","repository":{"id":46215441,"uuid":"448309235","full_name":"skito/ATMF-JS","owner":"skito","description":"Javascript support for ATMF","archived":false,"fork":false,"pushed_at":"2023-02-03T16:56:53.000Z","size":115,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T03:40:35.168Z","etag":null,"topics":["atmf","crossplatform","format","javascript","js","nodejs","open-source","react","template-engine"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skito.png","metadata":{"files":{"readme":"README-BROWSER.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-15T15:04:51.000Z","updated_at":"2023-02-01T13:50:45.000Z","dependencies_parsed_at":"2023-02-17T05:45:56.619Z","dependency_job_id":null,"html_url":"https://github.com/skito/ATMF-JS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skito/ATMF-JS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skito%2FATMF-JS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skito%2FATMF-JS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skito%2FATMF-JS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skito%2FATMF-JS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skito","download_url":"https://codeload.github.com/skito/ATMF-JS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skito%2FATMF-JS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281810223,"owners_count":26565462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atmf","crossplatform","format","javascript","js","nodejs","open-source","react","template-engine"],"created_at":"2024-12-12T11:13:52.951Z","updated_at":"2025-10-30T13:06:46.012Z","avatar_url":"https://github.com/skito.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Back to main document](https://github.com/skito/ATMF-JS)\n# ATMF-JS / Browser enviropment\n\n__Javascript support for ATMF (Advanced-Template-Markup-Format)__\n\n![GitHub release (latest by date)](https://img.shields.io/badge/production-ready-green)\n![GitHub release (latest by date)](https://img.shields.io/badge/coverage-100%25-green)\n\n\u0026nbsp;\n \n# Setup\nSimply load the ATMF browser library in your project. Then set the autodiscovery.\n```html\n\u003cscript type=\"module\" src=\"../../src/atmf/browser/browser.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.onload = function () {\n      // Configure auto discovery\n      ATMF.SetTemplateDiscoveryPath('../common/templates/', 'html');\n      ATMF.SetCultureDiscoveryPath('../common/culture');\n      ATMF.SetCulture('en-US');\n  };\n\u003c/script\u003e\n```\nYou can now start using ATMF. You can do so by adding ``data-atmf`` attributes to your DOM elements or by using the global selector function ``__()``. Let's try something simple. Add this code.\n\n```html\n\u003ch1 data-atmf=\"{$hello}\"\u003e\u003c/h1\u003e\n```\n\nThen load the page, open the browser console and type:\n```javascript\n__('$hello', 'Hellow World!')\n```\n\nThe ATMF browser library will watch all of your body DOM and will automatically evaluate ATMF markup as long as it's available in any ``data-atmf`` attribute.\n\n\u0026nbsp;\n\n# Advanced Usage\n__Global selector ``__()``__\n\n```javascript\n// Assign variables\n__('$fullname', 'Advanced-Template-Markup-Format');\n__('$shortname', 'ATMF');\n__('$pagetitle', '{$fullname \" (\" $shortname \")\"}');\n__('$slogan', 'Cultural made easy!');\n__('$userData', __escape('{$crossScripting}'));\n\n\n// Using ATMF native properties\nATMF.vars['slogan'] = 'Cultural made easy!';\nATMF.DiscoverTemplate('header').then(() =\u003e { /* Do something */ });\n\n// State management\nvar setTime = function () {\n    __('$timeNow', __('/date \"H:i:s\"'));\n};\nsetTime();\nsetInterval(setTime, 1000);\n```\n\n\u0026nbsp;\n\n# Usage Front-End (data attribute)\n```html\n\u003ch1 data-atmf=\"{$pageTitle}\"\u003e\u003c/h1\u003e\n```\n\n__Language resources__\n```html\n\u003ch1 data-atmf=\"{@page.title}\"\u003e\u003c/h1\u003e\n\u003ch1 data-atmf=\"{@page.theFox 10 red}\"\u003e\u003c/h1\u003e\n```\nTranslations available at ``demos/common/culture/`` folder.\n\n__Templates and functions__\n```html\n\u003c!-- Load ../common/pages/header.html template --\u003e\n\u003c!-- according to the autodiscovery function above --\u003e\n\u003cdiv data-atmf=\"{#template pages/header}\"\u003e\u003c/div\u003e \n\n\u003c!-- Inline templates --\u003e\n\u003cdiv data-atmf=\"{#template #inline}\"\u003e\n \u003c!-- \n     Use either \u003ctextarea\u003e or \u003cxmp\u003e as wrapper to bypass browser parsing\n     NOTE: \u003cxmp\u003e is depricated, but still supported in most browsers\n --\u003e\n \u003ctextarea\u003e\n   \u003ch1\u003e{@page.title}\u003c/h1\u003e\n   {#if $someVar}\n    \u003cdiv\u003eShow me in some condition\u003c/div\u003e\n   {#else}\n    \u003cdiv\u003eOtherwise show me\u003c/div\u003e\n   {#end}\n \u003c/textarea\u003e\n\u003c/div\u003e\n```\n\n__Extensions__\n```html\n\u003ch1 data-atmf=\"Today date is {/date 'M d, Y'}\"\u003e\u003c/h1\u003e\n```\n\n\u0026nbsp;\n\n# Usage Front-End (templates)\n__Variables__\n```html\n\u003ch1\u003e{$pageTitle}\u003c/h1\u003e\n```\n\n__Language resources__\n```html            \n\u003ch1\u003e{@page.title}\u003c/h1\u003e\n\u003ch1\u003e{@page.theFox 10 red}\u003c/h1\u003e\n```\nTranslations available at ``demos/common/culture/`` folder.\n\n__Functions - #each #if #else #end__\n```html\n\u003ctable style=\"min-width:500px\" cellspacing=\"10\"\u003e\n    \u003ctr style=\"font-weight:bold\"\u003e\n        \u003ctd\u003eAuthor Name\u003c/td\u003e\n        \u003ctd\u003eBooks\u003c/td\u003e\n        \u003ctd\u003eSold Out\u003c/td\u003e\n    \u003c/tr\u003e\n    {#each $authors as $author}\n        \u003ctr\u003e\n            \u003ctd\u003e\n                {$author.firstName \" \" $author.lastName}\n            \u003c/td\u003e\n            \u003ctd\u003e\n                \u003cul\u003e\n                {#each $author.books as $book}\n                    \u003cli\u003e{$book}\u003c/li\u003e\n                {#end}\n                \u003c/ul\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                {#if $author.soldOut}\n                    \u003cspan style=\"color:red\"\u003eSold out\u003c/span\u003e\n                {#else}\n                    \u003cspan style=\"color:green\"\u003eIn stock\u003c/span\u003e\n                {#end}\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    {#end}\n\u003c/table\u003e\n```\n\n__Extensions__\n```html\n\u003ch1\u003eToday date is {/date \"M d, Y\"}\u003c/h1\u003e\n```\n\n__Escaping with backslash__\n```html\n\u003ch1\u003e\\{@page.title}\u003c/h1\u003e\n```\n\nFull demo available ``demos/common/templates/`` folder.\n\n\u0026nbsp;\n\n# Custom Extensions\nDeclare your custom extensions with this interface.\n```javascript\nclass MyCustomExtension\n{    \n    constructor() {\n        this.str = \"My custom extension\";\n    }\n    \n    Get(args) \n    {\n        return this.str;\n    }\n    \n    Set(args, value) \n    {\n        this.str = value;\n    }\n    \n    static Register(ATMFEngine) {\n        ATMFEngine.extensions.Register('mycustom', new MyCustomExtension());\n    }\n}\n```\n\nThen in your ATMF setup code, call the register function\n```javascript\nwindow.addEventListener('load', (e) =\u003e {\n    MyCustomExtension.Register(ATMFEngine);\n};\n```\n\nUsing the extension\n```html\n\u003cspan data-atmf=\"{/mycustom}\"\u003e\u003c/span\u003e \u003c!-- OUTPUT: My custom extension --\u003e\n```\n\nUsing with JS selector\n```javascript\n__('/mycustom') // Returns \"My custom extension\"\n__('/mycustom', 'Another custom value') // Change the value\n__('/mycustom') // Returns \"Another custom value\"\n```\nFor more advanced example with arguments check the date core extension inside ``src/atmf/engine/ext/date.js``\n\n\u0026nbsp;\n\n# Prototyping\nTo make your own custom template and culture discovery you need to prototype the ATMF engine. [Learn more about it here](https://github.com/skito/ATMF-JS#prototyping).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskito%2Fatmf-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskito%2Fatmf-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskito%2Fatmf-js/lists"}