{"id":23338752,"url":"https://github.com/appfeel/templatecache","last_synced_at":"2025-07-16T15:42:04.964Z","repository":{"id":65374685,"uuid":"70630946","full_name":"appfeel/templatecache","owner":"appfeel","description":"angular templates to $templateCache","archived":false,"fork":false,"pushed_at":"2016-11-03T20:33:02.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T15:43:59.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/appfeel.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}},"created_at":"2016-10-11T20:07:10.000Z","updated_at":"2017-09-12T04:37:34.000Z","dependencies_parsed_at":"2023-01-20T01:25:16.187Z","dependency_job_id":null,"html_url":"https://github.com/appfeel/templatecache","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/appfeel/templatecache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Ftemplatecache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Ftemplatecache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Ftemplatecache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Ftemplatecache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfeel","download_url":"https://codeload.github.com/appfeel/templatecache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Ftemplatecache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265521961,"owners_count":23781590,"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":[],"created_at":"2024-12-21T03:16:19.088Z","updated_at":"2025-07-16T15:42:04.939Z","avatar_url":"https://github.com/appfeel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Template cache for angular apps\n\n[![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://npmjs.org/package/templatecache)\n[![NPM version](http://img.shields.io/npm/v/templatecache.svg?style=flat)](https://npmjs.org/package/templatecache)\n[![Downloads](http://img.shields.io/npm/dm/templatecache.svg?style=flat)](https://npmjs.org/package/templatecache)\n[![Build Status](http://img.shields.io/travis/appfeel/templatecache.svg?style=flat)](https://travis-ci.org/appfeel/templatecache)\n[![dependency status](https://img.shields.io/david/appfeel/templatecache.svg?style=flat)](https://david-dm.org/appfeel/templatecache)\n\nTranslates Angular html template files to a unique compressed javascript file that uses `$templateCache` directive.\n\n# Install\n\n```\nnpm i templatecache --save\n```\n\n# Use it\n\nWith a callback function:\n\n```js\ntemplatecache({\n    angularRoot: 'path/to/angular/app',\n}, function (err, templatejs) {\n    // err contains errors if any, null otherwise\n    // templatejs contains the generated javascript file\n});\n```\n\nOr as a promise:\n\n```js\ntemplatecache({\n    angularRoot: 'path/to/angular/app',\n})\n    .then(function (templatejs) {\n        // templatejs contains the generated javascript file\n    })\n    .catch(function (err) {\n        // called if there has been any error\n    });\n```\n\n# Options\n\nDefault options are the following ones:\n\n```js\nvar options = {\n    angularRoot: 'path/to/angular/app',\n    moduleName: 'templates',\n    isStandalone: false,\n    isNgAnnotate: false,\n    isCreateOutput: false,\n    templatesFilePath: 'path/to/templates.js',\n    progress: function (p) {\n        return true;\n    },\n    contentModifier: function (content, filePath) {\n        return content;\n    },\n};\n\ntemplatecache(options, function (err, templatejs) {\n\n});\n```\n\n\n## angularRoot (string, required)\nThe location of your Angular app. `templatecache` will search all `.html` files inside this directory, skipping the root `path/to/angular/app/index.html`.\n\n\n## moduleName (string, optional)\nThe name of the module that will be created.\n\n**Defaults**: `templates`\n\n\n## isStandalone (boolean, optional)\nWhen `true`, the module will be created as standalone, otherwise, as a dependency of moduleName.\nIn example, if modulename is `myTemplates`:\n\n- `isStandalone === false` will create `angular.module(\"myTemplates\")`\n- `isStandalone === true` will create `angular.module(\"myTemplates\",[])`\n\n**Defaults**: `false`\n\n\n## isNgAnnotate (boolean, optional)\nWhen `true`, `$templateCache` variable will be annotated, otherwise it won't be:\n\n- `isNgAnnotate === false` will create `angular.module(\"myTemplates\").run(function($templateCache){ ... })`\n- `isNgAnnotate === true` will create `angular.module(\"myTemplates\").run([\"$templateCache\",function($templateCache){ ... }])`\n\n**Defaults**: `false`\n\n\n## isCreateOutput (boolean, optional)\nWhen true, the output file will be created. If `templatesFilePath` is specified then the file will be created in the specified value, otherwise in the default location (`path.resolve(path.join(angularRoot, 'templates.js'));`).\n\n**Defaults**: `false`\n\n\n## templatesFilePath (string, optional)\nThe path to the templates file (in case a file will be generated). If the path does not exist, this module will create the needed subdirectories. If the file already exists, it will be replaced. This script is the one that should be included in your `index.html`.\n\n```html\n\u003cscript src=\"path/to/templates.js\"\u003e\u003c/script\u003e\n```\n\nIf this value starts with a slash  (`'/templates.js'`) it will be considered as an absolute path and it will be resolved as it is.\nIf this value starts with a dot-slash (`'./templates.js'`) it will be considered as a relative path from where this module is being invoked.\nOtherwise it will be resolved relative to `angularRoot`.\n\n**Defaults**: `'templates.js'`\n\n\n## progress (function, optional)\nCalled each time a template is processed. It has the following signature:\n\n```js\nfunction progress(filePath) {\n    return true;\n}\n```\n\nWhen it returns `true`, the file specified in `filePath` will be processed, otherwise it will be skipped.\n\n**Defaults**: `function (p) { return true; }`\n\n\n## contentModifier\nCalled each time a template has been read. It allows to modify the content of the template. It has the following signature:\n\n```js\nfunction contentModifier(content, filePath, callback) {\n    return content;\n}\n```\n\nIt allows to return an string with same/new content, a `Promise` that resolves to the same/new content or rejects (will fail whole process) or it can be resolved with `callback(err, newContent)` (if `err` is specified it will fail the whole process). If an error is thrown it will fail the whole process. \n\n**Defaults**: `function (content) { return content; }`\n\n\n# License: MIT\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2016 AppFeel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n*\u003cp style=\"font-size: small;\" align=\"right\"\u003e\u003ca color=\"#232323;\" href=\"http://appfeel.com\"\u003eMade in Barcelona with \u003cspan color=\"#FCB\"\u003e\u003c3\u003c/span\u003e and \u003cspan color=\"#BBCCFF\"\u003eCode\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfeel%2Ftemplatecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfeel%2Ftemplatecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfeel%2Ftemplatecache/lists"}