{"id":13424212,"url":"https://github.com/taiga-family/ng-polymorpheus","last_synced_at":"2025-05-14T18:04:44.468Z","repository":{"id":38992730,"uuid":"211065633","full_name":"taiga-family/ng-polymorpheus","owner":"taiga-family","description":"Polymorpheus is a tiny library for polymorphic templates in Angular.","archived":false,"fork":false,"pushed_at":"2025-05-14T06:41:50.000Z","size":113885,"stargazers_count":397,"open_issues_count":2,"forks_count":22,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-14T06:47:59.287Z","etag":null,"topics":["angular","customization","hacktoberfest","ng-template","polymorphic","template","templates"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/polymorpheus-demo","language":"TypeScript","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/taiga-family.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-26T10:44:34.000Z","updated_at":"2025-05-14T05:35:43.000Z","dependencies_parsed_at":"2023-10-23T20:39:06.992Z","dependency_job_id":"1f29c04b-007b-469a-8260-03c4c8658103","html_url":"https://github.com/taiga-family/ng-polymorpheus","commit_stats":{"total_commits":805,"total_committers":16,"mean_commits":50.3125,"dds":"0.23478260869565215","last_synced_commit":"2b0f18b5d7f2697ff3f84c9af3d53fd2900b8b0f"},"previous_names":["tinkoffcreditsystems/ng-polymorpheus","tinkoff/ng-polymorpheus"],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiga-family%2Fng-polymorpheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiga-family%2Fng-polymorpheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiga-family%2Fng-polymorpheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiga-family%2Fng-polymorpheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taiga-family","download_url":"https://codeload.github.com/taiga-family/ng-polymorpheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254121962,"owners_count":22018252,"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":["angular","customization","hacktoberfest","ng-template","polymorphic","template","templates"],"created_at":"2024-07-31T00:00:50.238Z","updated_at":"2025-05-14T18:04:39.459Z","avatar_url":"https://github.com/taiga-family.png","language":"TypeScript","funding_links":[],"categories":["Инструменты","Third Party Components"],"sub_categories":["Layout"],"readme":"# Polymorpheus\n\n[![npm version](https://img.shields.io/npm/v/@taiga-ui/polymorpheus.svg)](https://npmjs.com/package/@taiga-ui/polymorpheus)\n[![Coverage Status](https://codecov.io/gh/taiga-family/ng-polymorpheus/branch/master/graphs/badge.svg)](https://app.codecov.io/gh/taiga-family/ng-polymorpheus/tree/master/projects)\n[![angular-open-source-starter](https://img.shields.io/badge/made%20with-angular--open--source--starter-d81676?logo=angular)](https://github.com/taiga-family/angular-open-source-starter)\n[![telegram chat](https://img.shields.io/badge/support-Contact%20us-blue)](https://t.me/taiga_ui)\n\n**Polymorpheus** is a tiny library for polymorphic templates in Angular.\n\nIt is 1 KB gzip, dependency free and allows you to make pretty cool things.\n\n![Polymorpheus](projects/demo/assets/logo.svg)\n\n## What does it do?\n\nIt abstracts over different ways of view customization in Angular with one simple _structural directive_:\n\n```html\n\u003cng-container *polymorpheusOutlet=\"content as text; context: context\"\u003e{{text}}\u003c/ng-container\u003e\n```\n\n**Content** accepts:\n\n- primitives like `number` or `string`\n- functions that take `context` as argument and return a primitive\n- templates that get instantiated with given `context`\n- components that would get `context` injected through DI\n\n**Context** is optional when you need your **content** to adapt to the situation\n\n## How to use it?\n\nTypical use case would be a component that accepts visual customization and defines context by itself. Say a menu list\nwhere you can configure how each item should look like by passing a template. And context would be item itself and, for\nexample, whether it is focused or not.\n\nPlease see [extensive demo](https://stackblitz.com/edit/polymorpheus-demo) (wait for packages to install and run\n`npm start`).\n\nYou can also\n[read about this concept in detail](https://medium.com/angular-in-depth/agnostic-components-in-angular-2427923b742d).\n\n### Accessing context in dynamic component\n\nIf you use component content you can inject context with `POLYMORPHEUS_CONTEXT` token.\n\n**Important!** This object is _live_ so if you change it, your component will not be recreated:\n\n```ts\n@Component({\n  template: `\n    {{ context.active }}\n  `, // \u003c-- this will automatically update\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MyComponent {\n  constructor(@Inject(POLYMORPHEUS_CONTEXT) readonly context: {active: boolean}) {}\n}\n```\n\n### Adding type to template context\n\nYou can use `polymorpehus` directive to add type to template context:\n\n```typescript\nreadonly context!: { $implicit: number };\n```\n\n```html\n\u003cng-template\n  #template=\"polymorpheus\"\n  [polymorpheus]=\"context\"\n  let-item\n\u003e\n  {{ item.toFixed(2) }} \u003c-- type 'number'\n\u003c/ng-template\u003e\n```\n\n## Core team\n\n\u003ctable\u003e\n    \u003ctr\u003e\n       \u003ctd align=\"center\"\u003e\n            \u003ca href=\"https://twitter.com/waterplea\"\n                \u003e\u003cimg\n                    src=\"https://github.com/waterplea.png?size=100\"\n                    width=\"100\"\n                    style=\"margin-bottom: -4px; border-radius: 8px;\"\n                    alt=\"Alex Inkin\"\n                /\u003e\u003cbr /\u003e\u003cb\u003eAlex Inkin\u003c/b\u003e\u003c/a\n            \u003e\n            \u003cdiv style=\"margin-top: 4px\"\u003e\n                \u003ca\n                    href=\"https://twitter.com/waterplea\"\n                    title=\"Twitter\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg\"\n                /\u003e\u003c/a\u003e\n                \u003ca href=\"https://github.com/waterplea\" title=\"Github\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg\"\n                /\u003e\u003c/a\u003e\n                \u003ca\n                    href=\"https://t.me/waterplea\"\n                    title=\"Telegram\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg\"\n                /\u003e\u003c/a\u003e\n            \u003c/div\u003e\n        \u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\n            \u003ca href=\"https://twitter.com/marsibarsi\"\n                \u003e\u003cimg\n                    src=\"https://github.com/marsibarsi.png?size=100\"\n                    width=\"100\"\n                    style=\"margin-bottom: -4px; border-radius: 8px;\"\n                    alt=\"Roman Sedov\"\n                /\u003e\u003cbr /\u003e\u003cb\u003eRoman Sedov\u003c/b\u003e\u003c/a\n            \u003e\n            \u003cdiv style=\"margin-top: 4px\"\u003e\n                \u003ca\n                    href=\"https://twitter.com/marsibarsi\"\n                    title=\"Twitter\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg\"\n                /\u003e\u003c/a\u003e\n                \u003ca\n                    href=\"https://github.com/marsibarsi\"\n                    title=\"GitHub\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg\"\n                /\u003e\u003c/a\u003e\n                \u003ca\n                    href=\"https://t.me/marsibarsi\"\n                    title=\"Telegram\"\n                    \u003e\u003cimg\n                        width=\"16\"\n                        src=\"https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg\"\n                /\u003e\u003c/a\u003e\n            \u003c/div\u003e\n        \u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n**ng-polymorpheus** is a part of [Taiga UI](https://github.com/taiga-family/taiga-ui) libraries family which is backed\nand used by a large enterprise. This means you can rely on timely support and continuous development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaiga-family%2Fng-polymorpheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaiga-family%2Fng-polymorpheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaiga-family%2Fng-polymorpheus/lists"}