{"id":14965476,"url":"https://github.com/inteve/simple-components","last_synced_at":"2026-01-19T04:01:25.910Z","repository":{"id":56992729,"uuid":"353055686","full_name":"inteve/simple-components","owner":"inteve","description":"Simple independent components for Latte/Nette.","archived":false,"fork":false,"pushed_at":"2025-07-01T10:02:11.000Z","size":37,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T10:25:02.622Z","etag":null,"topics":["latte","nette","nette-latte","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inteve.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license.md","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},"funding":{"custom":"https://www.janpecha.cz/donate/"}},"created_at":"2021-03-30T15:46:57.000Z","updated_at":"2025-07-01T10:02:14.000Z","dependencies_parsed_at":"2024-09-13T23:39:30.507Z","dependency_job_id":"11003805-0807-48af-ac3f-ac438ed60eaa","html_url":"https://github.com/inteve/simple-components","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"d0484266ce5622675acf9a0966b0b1035190eefd"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/inteve/simple-components","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inteve%2Fsimple-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inteve%2Fsimple-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inteve%2Fsimple-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inteve%2Fsimple-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inteve","download_url":"https://codeload.github.com/inteve/simple-components/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inteve%2Fsimple-components/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28561602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["latte","nette","nette-latte","php"],"created_at":"2024-09-24T13:34:48.375Z","updated_at":"2026-01-19T04:01:25.896Z","avatar_url":"https://github.com/inteve.png","language":"PHP","funding_links":["https://www.janpecha.cz/donate/"],"categories":[],"sub_categories":[],"readme":"# Inteve\\SimpleComponents\n\n[![Build Status](https://github.com/inteve/simple-components/workflows/Build/badge.svg)](https://github.com/inteve/simple-components/actions)\n[![Downloads this Month](https://img.shields.io/packagist/dm/inteve/simple-components.svg)](https://packagist.org/packages/inteve/simple-components)\n[![Latest Stable Version](https://poser.pugx.org/inteve/simple-components/v/stable)](https://github.com/inteve/simple-components/releases)\n[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/inteve/simple-components/blob/master/license.md)\n\nSimple independent components for Latte templates.\n\n\u003ca href=\"https://www.janpecha.cz/donate/\"\u003e\u003cimg src=\"https://buymecoffee.intm.org/img/donate-banner.v1.svg\" alt=\"Donate\" height=\"100\"\u003e\u003c/a\u003e\n\n\n## Installation\n\n[Download a latest package](https://github.com/inteve/simple-components/releases) or use [Composer](http://getcomposer.org/):\n\n```\ncomposer require inteve/simple-components\n```\n\nInteve\\SimpleComponents requires PHP 8.0 or later.\n\n\n## Usage\n\n### 1. create components factory\n\n```php\nuse Inteve\\SimpleComponents;\n\n\nclass MyComponentFactory implements SimpleComponents\\ComponentFactory\n{\n\tpublic function create($componentName, array $args = [])\n\t{\n\t\tif ($componentName === 'menu') {\n\t\t\treturn new SimpleComponents\\GenericComponent(__DIR__ . '/components/Menu.latte');\n\n\t\t} elseif ($componentName === 'breadcrumbs') {\n\t\t\treturn new SimpleComponents\\GenericComponent(__DIR__ . '/components/Breadcrumbs.latte', $args);\n\t\t}\n\n\t\treturn NULL;\n\t}\n}\n```\n\n\n### 2. register `{component}` macro\n\n**In plain PHP:**\n\n```php\n$latte = new Latte\\Engine;\n$componentFactory = new MyComponentFactory;\n\\Inteve\\SimpleComponents\\LatteMacros::installToLatte($latte, $componentFactory);\n```\n\n\n**In Nette presenter:**\n\n```php\nabstract class BasePresenter extends \\Nette\\Application\\UI\\Presenter\n{\n\t/** @var \\Inteve\\SimpleComponents\\ComponentFactory @inject */\n\tpublic $componentFactory;\n\n\n\tprotected function createTemplate()\n\t{\n\t\t$template = parent::createTemplate();\n\t\tassert($template instanceof \\Nette\\Bridges\\ApplicationLatte\\Template);\n\t\t\\Inteve\\SimpleComponents\\LatteMacros::installToLatte($template-\u003egetLatte(), $this-\u003ecomponentFactory);\n\t\treturn $template;\n\t}\n}\n```\n\n\n### 3. use it in your app template\n\n```latte\n{block content}\n\t\u003ch1\u003eMy Page\u003c/h1\u003e\n\n\t{component menu}\n\t{component breadcrumbs, items =\u003e $breadcrumbItems}\n\n\t\u003cp\u003eLorem ipsum dolor sit amet.\u003c/p\u003e\n{/block}\n```\n\n\n## Prepared implementations\n\n### `DirectoryFactory`\n\nLoads template files from specified directory.\n\n```\n/app\n\t/components\n\t\tbreadcrumbs.latte\n\t\tmenu.latte\n```\n\n```php\n$componentFactory = new SimpleComponents\\DirectoryFactory('/path/to/app/components');\n```\n\n```latte\n{component menu}\n{component breadcrumbs}\n```\n\n\n### `MultiFactory`\n\nPacks multiple `ComponentFactory` implementations to one class.\n\n```php\n$componentFactory = new SimpleComponents\\MultiFactory([\n\tnew MyComponentFactory,\n\tnew SimpleComponents\\DirectoryFactory('/path/to/app/components')\n]);\n```\n\n```latte\n{component menu}\n{component breadcrumbs}\n{component someMyComponent}\n```\n\n\n## Typed templates\n\n```php\nclass Breadcrumbs implements SimpleComponents\\Component\n{\n\t/** @var BreadcrumbItem[] */\n\tprivate $items;\n\n\n\t/**\n\t * @param BreadcrumbItem[] $items\n\t */\n\tpublic function __construct(array $items)\n\t{\n\t\t$this-\u003eitems = $items;\n\t}\n\n\n\tpublic function getFile()\n\t{\n\t\treturn __DIR__ . '/components/breadcrumbs.latte';\n\t}\n\n\n\tpublic function getParameters()\n\t{\n\t\treturn [\n\t\t\t'items' =\u003e $this-\u003eitems;\n\t\t];\n\t}\n}\n\n\nclass MyComponentFactory implements SimpleComponents\\ComponentFactory\n{\n\tpublic function create($componentName, array $args = [])\n\t{\n\t\tif ($componentName === 'breadcrumbs') {\n\t\t\treturn new Breadcrumbs($args['items']);\n\t\t}\n\n\t\treturn NULL;\n\t}\n}\n```\n\n```latte\n{component breadcrumbs, items =\u003e $breadcrumbsItems}\n```\n\n\n------------------------------\n\nLicense: [New BSD License](license.md)\n\u003cbr\u003eAuthor: Jan Pecha, https://www.janpecha.cz/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteve%2Fsimple-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finteve%2Fsimple-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteve%2Fsimple-components/lists"}