{"id":21319529,"url":"https://github.com/simplajs/simpla-collection","last_synced_at":"2026-04-10T10:05:17.401Z","repository":{"id":58239162,"uuid":"90317404","full_name":"simplajs/simpla-collection","owner":"simplajs","description":"Create editable collections of content straight in HTML","archived":false,"fork":false,"pushed_at":"2017-12-15T05:49:12.000Z","size":142,"stargazers_count":12,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-10T13:34:14.903Z","etag":null,"topics":["collection","content-management","custom-element","simpla","web-components"],"latest_commit_sha":null,"homepage":"https://www.simplajs.org","language":"HTML","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/simplajs.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":"2017-05-04T23:09:03.000Z","updated_at":"2023-09-08T17:24:30.000Z","dependencies_parsed_at":"2022-08-31T00:40:31.084Z","dependency_job_id":null,"html_url":"https://github.com/simplajs/simpla-collection","commit_stats":null,"previous_names":["simplaelements/simpla-collection"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/simplajs/simpla-collection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplajs%2Fsimpla-collection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplajs%2Fsimpla-collection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplajs%2Fsimpla-collection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplajs%2Fsimpla-collection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplajs","download_url":"https://codeload.github.com/simplajs/simpla-collection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplajs%2Fsimpla-collection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264939252,"owners_count":23686204,"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":["collection","content-management","custom-element","simpla","web-components"],"created_at":"2024-11-21T19:42:41.294Z","updated_at":"2026-04-10T10:05:17.393Z","avatar_url":"https://github.com/simplajs.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simpla Collection\n[![Build status][travis-badge]][travis-url] ![Size][size-badge] ![Version][bower-badge] [![Published][webcomponents-badge]][webcomponents-url]\n\nSimpla-collection lets you create dynamic collections of content in HTML. It consumes a HTML template, which users can add, remove, and reorder instances of inline on your page. It's built on the [Simpla][simpla] content system.\n\n\u003c!---\n```\n\u003ccustom-element-demo\u003e\n  \u003ctemplate\u003e\n    \u003cscript src=\"../webcomponentsjs/webcomponents-lite.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/simpla@^2.0.0\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      Simpla.init('local');\n      Simpla.editable(true);\n    \u003c/script\u003e\n\n    \u003clink rel=\"import\" href=\"simpla-collection.html\"\u003e\n    \u003clink rel=\"import\" href=\"../simpla-img/simpla-img.html\"\u003e\n\n    \u003cstyle\u003e\n      body {\n        min-height: 350px\n      }\n      img {\n        max-width: 15rem;\n      }\n      simpla-collection {\n        margin-top: 2rem;\n      }\n    \u003c/style\u003e\n    \u003cnext-code-block\u003e\u003c/next-code-block\u003e\n  \u003c/template\u003e\n\u003c/custom-element-demo\u003e\n```\n--\u003e\n```html\n\u003csimpla-collection path=\"/collection\"\u003e\n  \u003ctemplate\u003e\n    \u003cimg is=\"simpla-img\" path=\"/collection/[item]\"\u003e\n  \u003c/template\u003e\n\u003c/simpla-collection\u003e\n```\n\n### Contents\n\n- [Installation and setup](#installation-and-setup)\n- [Editing a collection](#editing-a-collection)\n- [Saving collections](#saving-collections)\n- [Using simpla-paths](#using-simpla-paths)\n- [Custom item names](#custom-item-names)\n- [Collection data model](#collection-data-model)\n- [Readonly](#readonly)\n- [Contributing](#contributing)\n\n### Resources\n\n- [API reference][api]\n- [Demo][demo]\n- [License][license]\n\n## Installation and setup\n\nInstall simpla-collection with Bower (Yarn support coming soon)\n\n```sh\n$ bower i simpla-collection --save\n```\n\n[Setup Simpla][simpla-setup] on your page, then import simpla-collection into your `\u003chead\u003e`\n\n```html\n\u003clink rel=\"import\" href=\"/bower_components/simpla-collection/simpla-collection.html\"\u003e\n```\n\nUse `\u003csimpla-collection\u003e` wherever you want to create a collection of items. Define the item template in a `\u003ctemplate\u003e` inside simpla-collection. Give each collection a unique `path`, where it will store its content in your project. Simpla-collection also exposes an `[item]` key to use in the paths of Simpla elements inside your template.\n\n```html\n\u003csimpla-collection path=\"/collection\"\u003e\n  \u003ctemplate\u003e\n    \u003cimg is=\"simpla-img\" path=\"/collection/[item]\"\u003e\n  \u003c/template\u003e\n\u003c/simpla-collection\u003e\n```\n\n## Editing a collection\n\nManage the items in your collection by entering edit mode with Simpla (which makes all Simpla elements on a page editable) or setting the `editable` property directly on the element.\n\n```js\n// Enter edit mode\nSimpla.editable(true);\n```\n\n```html\n\u003c!-- Make only this collection editable --\u003e\n\u003csimpla-collection path=\"/collection\" editable\u003e\n  \u003ctemplate\u003e...\u003c/template\u003e\n\u003c/simpla-collection\u003e\n```\n\nEntering edit mode with Simpla is the recommended way to edit collections. It ensures all elements on a page remain in sync and updates Simpla's public `'editable'` state, which other elements may rely on.\n\n## Saving collections\n\nSave a `simpla-collection` by calling Simpla's `save` method, which will save all modified content on the page. It returns a promise.\n\n```js\n// Save all modified Simpla content\nSimpla.save();\n```\n\n\u003e You must be authenticated with Simpla before saving content\n\n## Using simpla-paths\n\nSimpla-collection works with [simpla-paths](https://github.com/SimplaElements/simpla-paths), which lets you build content paths for Simpla elements declaratively with HTML attributes. This is useful for creating more complex collection items\n\n```html\n\u003csimpla-colleciton sid=\"faqs\"\u003e\n  \u003ctemplate\u003e\n    \u003cdiv sid=\"[item]\"\u003e\n      \u003csimpla-text sid=\"question\"\u003e\u003c/simpla-text\u003e \n      \u003csimpla-text sid=\"answer\"\u003e\u003c/simpla-text\u003e \n    \u003c/div\u003e\n  \u003c/template\u003e\n\u003c/simpla-colleciton\u003e\n```\n\n## Custom item names\n\nYou can change the default item name used by simpla-collection with the `as` property. Setting a custom item name changes the key used for templating Simpla paths, as well as labels throughout simpla-collection's edit UI. It doesn't effect the data saved by the colleciton.\n\n```html\n\u003csimpla-collection path=\"/gallery\" as=\"image\"\u003e\n  \u003ctemplate\u003e\n    \u003cimg is=\"simpla-img\" path=\"/gallery/[image]\"\u003e\n  \u003c/template\u003e\n\u003c/simpla-collection\u003e \n```\n\n## Collection data model\n\nSimpla-collection stores meta information about its items on Simpla's API and in its `items` property as an ordered Array:\n\n```js\n[\n  { id: 'dwubz' },\n  { id: 'h3sqb' },\n  ...\n]\n```\n\nThe order of the items objects in the `items` array determines the order of the items rendered in the collection.\n\nEach item has a unique ID, which is generated for the `[item]` templating key in the item template. A single item ID can map to several paths of content. For example, given the following template:\n\n```html\n\u003csimpla-collection path=\"/gallery\"\u003e\n  \u003ctemplate\u003e\n    \u003cimg is=\"simpla-img\" path=\"/gallery/[item]/img\"\u003e\n    \u003csimpla-text path=\"/gallery/[item]/caption\"\u003e\u003c/simpla-text\u003e\n  \u003c/template\u003e\n\u003c/simpla-collection\u003e \n```\n\nA single item ID (eg: `'dbuwz'`) would map to the following paths:\n\n```\n/gallery/dbuwz/img\n/gallery/dbuwz/caption\n```\n\n## Readonly\n\nSimpla-collection has a `readonly` property that stops it from becoming editable, even if Simpla is in edit mode or you try to set `editable` on the element directly. This is useful for using simpla-collection to purely consume and display content from Simpla's API.\n\n```html\n\u003csimpla-collection path=\"/collection\" readonly\u003e\n  \u003ctemplate\u003e...\u003c/template\u003e\n\u003c/simpla-collection\u003e\n```\n\n## Contributing\n\nIf you find any issues with simpla-collection please report them! If you'd like to see a new feature in supported file an issue or let us know in Simpla's public [Slack group](https://slack.simpla.io). We also happily accept PRs. \n\n***\n\nMIT © [Simpla][simpla]\n\n[simpla]: https://www.simpla.io\n[simpla-setup]: https://docs.simpla.io/guides/get-started.html\n\n[api]: https://www.webcomponents.org/element/simplaio/simpla-collection/page/API.md\n[demo]: https://www.webcomponents.org/element/simplaio/simpla-collection/demo/demo/index.html\n[license]: https://github.com/simplaio/simpla-collection/blob/master/LICENSE\n\n[bower-badge]: https://img.shields.io/bower/v/simpla-collection.svg\n[bowerlicense-badge]: https://img.shields.io/bower/l/simpla-collection.svg\n[travis-badge]: https://img.shields.io/travis/simplaio/simpla-collection.svg\n[travis-url]: https://travis-ci.org/simplaio/simpla-collection\n[size-badge]: http://img.badgesize.io/simplaio/simpla-collection/master/simpla-collection.html?compression=gzip\u0026label=render_bundle_%28gzip%29\n[webcomponents-badge]: https://img.shields.io/badge/webcomponents.org-published-blue.svg\n[webcomponents-url]: https://www.webcomponents.org/element/simplaio/simpla-collection\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplajs%2Fsimpla-collection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplajs%2Fsimpla-collection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplajs%2Fsimpla-collection/lists"}