{"id":15103073,"url":"https://github.com/jankapunkt/meteor-template-loader","last_synced_at":"2025-04-05T11:43:04.586Z","repository":{"id":81102728,"uuid":"301816418","full_name":"jankapunkt/meteor-template-loader","owner":"jankapunkt","description":"The one and only template loader you need! Allows to import Templates dynamically at lookup-time. All code \u003c 200 lines.","archived":false,"fork":false,"pushed_at":"2025-01-13T13:18:50.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T22:46:30.760Z","etag":null,"topics":["blaze","blazejs","dynamic-imports","meteor","meteor-blaze","meteorjs","template"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jankapunkt.png","metadata":{"files":{"readme":"README.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}},"created_at":"2020-10-06T18:16:36.000Z","updated_at":"2020-12-18T07:08:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e36b8cc-2152-4aad-af59-20098969518e","html_url":"https://github.com/jankapunkt/meteor-template-loader","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"9c2b1287dcf20dad174e35b66c52d62cae19c0ee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-template-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-template-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-template-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-template-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jankapunkt","download_url":"https://codeload.github.com/jankapunkt/meteor-template-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332526,"owners_count":20921852,"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","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":["blaze","blazejs","dynamic-imports","meteor","meteor-blaze","meteorjs","template"],"created_at":"2024-09-25T19:20:45.686Z","updated_at":"2025-04-05T11:43:04.564Z","avatar_url":"https://github.com/jankapunkt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meteor Template Loader\n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n![GitHub file size in bytes](https://img.shields.io/github/size/jankapunkt/meteor-template-loader/template-loader.js?style=plastic)\n![GitHub](https://img.shields.io/github/license/jankapunkt/meteor-template-loader)\n\n\nThe one and only template loader you need! \nAllows to import Templates dynamically at lookup-time.\nAll code \u003c 200 lines.\n\n\n## How it works\n\nBlaze usually requires a Template to exist when looking it up to render it's\ncontent to the DOM. However, a `Blaze.View` is constructed reactively, waiting for the template\ninstance to be created, first. \n\nThis mechanism can be exploited in order to \"wait\" until the Template\nis imported and from there run like with any other Template.\n\n## Installation and usage\n\nInstall this package via\n\n```bash\n$ meteor add jkuester:template-loader\n```\n\nThen import it anywhere soon in your client startup order and add the Templates\nthat are common to be loaded dynamically.\n\nHowever, you need to initialize it once beforehand, otherwise there won't be any\ninterception of the Template lookup/include mechanism.\n\nConsider the following example:\n\n*`client/main.js`*\n```javascript\nimport { TemplateLoader } from 'meteor/jkuester:template-loader'\n\nTemplateLoader.enable()\n    .register('myForm', async () =\u003e import('../path/to/myForm'))\n    .register('myList', async () =\u003e import('../path/to/myList'))\n    .register('myUser', async () =\u003e import('../path/to/myUser'))\n    .register('myCard', async () =\u003e {\n      const { dependency } = await import('../path/to/dependency')\n      const { cardExport } = await import('../path/to/myCard')\n      return  cardExport.inject(dependency)\n    })\n```\n\nAll these Templates are now automatically loaded via the given loader function.\nAs you can see, the operation is chainable and you can also include complex\nimport logic into the loader function.\n\nNote, the Templates will not be imported before there is no other Template, that\nincludes them in it's HTML/SpaceBars code (or until it is manually imported).\n\nYou can add more Templates to autoload at any time.\n\nDo not add the `import` function directly or it will trigger the import \nimmediately and that would defy the purpose of this package:\n\n```javascript\n// XXX DO NOT DO IT LIKE THIS\nTemplateLoader.register('myForm', import('../path/to/myForm'))\n```\n\n## Why do I want this?\n\nOnce your application bundle grows beyond 1MB (which can happen very fast!) you\nneed to consider dynamic imports to reduce initial bundle size.\n\nA large initial bundle will rapidly delay the time to interact and may shut out\nusers with lower bandwidth. By dynamically importing Templates you can ensure to\ndeliver complex applications with great speed.\n\n## Contribution\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-template-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjankapunkt%2Fmeteor-template-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-template-loader/lists"}