{"id":24983678,"url":"https://github.com/posthtml/posthtml-modules","last_synced_at":"2025-04-11T20:51:41.237Z","repository":{"id":8677266,"uuid":"59292893","full_name":"posthtml/posthtml-modules","owner":"posthtml","description":"Modules Plugin","archived":false,"fork":false,"pushed_at":"2023-03-15T11:43:58.000Z","size":1892,"stargazers_count":84,"open_issues_count":11,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T21:06:06.618Z","etag":null,"topics":[],"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/posthtml.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":null,"patreon":"posthtml","open_collective":"posthtml","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-05-20T12:34:58.000Z","updated_at":"2024-09-17T23:10:28.000Z","dependencies_parsed_at":"2023-01-13T14:56:22.539Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/posthtml-modules","commit_stats":{"total_commits":128,"total_committers":14,"mean_commits":9.142857142857142,"dds":0.7421875,"last_synced_commit":"02ba19849920fd05ba4535aeb18ca3f239c9900a"},"previous_names":["canvaskisa/posthtml-modules"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-modules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247929485,"owners_count":21019894,"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":"2025-02-04T09:20:16.460Z","updated_at":"2025-04-11T20:51:41.206Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"[![NPM][npm]][npm-url]\n[![Deps][deps]][deps-url]\n[![Tests][travis]][travis-url]\n[![Coverage][cover]][cover-url]\n[![XO Code Style][style]][style-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"220\" height=\"150\" title=\"PostHTML\" src=\"http://posthtml.github.io/posthtml/logo.svg\"\u003e\n  \u003ch1\u003eModules Plugin\u003c/h1\u003e\n  \u003cp\u003eImport and process HTML Modules with PostHTML\u003c/p\u003e\n\u003c/div\u003e\n\n## Install\n\n```bash\nnpm i -D posthtml-modules\n```\n\n## Example\n\n```html\n\u003c!-- index.html --\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n  \u003cmodule href=\"./module.html\"\u003e\n    title\n  \u003c/module\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n```html\n\u003c!-- module.html --\u003e\n\u003cheader\u003e\n  \u003ch1\u003e\n    Test \u003ccontent\u003e\u003c/content\u003e\n  \u003c/h1\u003e\n\u003c/header\u003e\n```\n\n```js\nconst { readFileSync } = require('fs')\nconst posthtml = require('posthtml')\nconst options = { /* see available options below */ }\n\nposthtml()\n  .use(require('posthtml-modules')(options))\n  .process(readFileSync('index.html', 'utf8'))\n  .then((result) =\u003e result)\n  });\n```\n\n```html\n\u003chtml\u003e\n \u003cbody\u003e\n   \u003cheader\u003e\n     \u003ch1\u003eTest title\u003c/h1\u003e\n   \u003c/header\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Options\n\n### `root`\n\nType: `string`\\\nDefault: `./`\n\nRoot path for modules lookup.\n\n### `plugins`\n\nType: `array | function`\\\nDefault: `[]`\n\nPostHTML plugins to apply for every parsed module.\n\nIf a function provided, it will be called with module's file path.\n\n### `from`\n\nType: `string`\\\nDefault: `''`\n\nRoot filename for processing apply, needed for path resolving (it's better to always provide it).\n\n### `initial`\n\nType: `boolean`\\\nDefault: `false`\n\nApply plugins to root file after modules processing.\n\n### `tag`\n\nType: `string`\\\nDefault: `module`\n\nUse a custom tag name.\n\n### `attribute`\n\nType: `string`\\\nDefault: `href`\n\nUse a custom attribute name.\n\n### `locals`\n\nType: `object`\\\nDefault: `{}`\n\nPass data to the module.\n\nIf present, the JSON object from the `locals=\"\"` attribute will be merged on top of this, overwriting any existing values.\n\n### `attributeAsLocals`\n\nType: `boolean`\\\nDefault: `false`\n\nAll attributes on `\u003cmodule\u003e\u003c/module\u003e` will be added to [locals](#locals)\n\n### `parser`\n\nType: `object`\\\nDefault: `{}`\n\nOptions for the PostHTML parser.\n\nBy default, [`posthtml-parser`](https://github.com/posthtml/posthtml-parser) is used.\n\n### `expressions`\n\nType: `object`\\\nDefault: `{}`\n\nOptions to forward to [posthtml-expressions](https://github.com/posthtml/posthtml-expressions), like custom delimiters for example. Available options can be found [here](https://github.com/posthtml/posthtml-expressions#options).\n\n\n## Component options\n\n### `locals`\n\nYou can pass data to a module using a `locals=\"\"` attribute.\n\nMust be a valid JSON object.\n\nExample:\n\n```handlebars\n\u003c!-- module.html --\u003e\n\u003cp\u003eThe foo is {{ foo }} in this one.\u003c/p\u003e\n\u003ccontent\u003e\u003c/content\u003e\n```\n\n```handlebars\n\u003c!-- index.html --\u003e\n\u003cmodule href=\"./module.html\" locals='{\"foo\": \"strong\"}'\u003e\n  \u003cp\u003eOr so they say...\u003c/p\u003e\n\u003c/module\u003e\n```\n\n### Result\n\n```html\n\u003cp\u003eThe foo is strong in this one.\u003c/p\u003e\n\u003cp\u003eOr so they say...\u003c/p\u003e\n```\n\n### `attributeAsLocals`\n\nAll attributes on `\u003cmodule\u003e\u003c/module\u003e` will be added to [locals](#locals)\n\nExample:\n\n```handlebars\n\u003c!-- module.html --\u003e\n\u003cdiv class=\"{{ class }}\" id=\"{{ id }}\" style=\"{{ style }}\"\u003e\n  \u003ccontent\u003e\u003c/content\u003e\n\u003c/div\u003e\n```\n\n```handlebars\n\u003c!-- index.html --\u003e\n\u003cmodule \n  href=\"module.html\" \n  class=\"text-center uppercase\" \n  id=\"example\"\n  style=\"display: flex; gap: 2;\"\n\u003e\n  Module content\n\u003c/module\u003e\n```\n\n### Result\n\n```html\n\u003cdiv class=\"text-center uppercase\" id=\"example\" style=\"display: flex; gap: 2;\"\u003e\n  Module content\n\u003c/div\u003e\n```\n\n[npm]: https://img.shields.io/npm/v/posthtml-modules.svg\n[npm-url]: https://npmjs.com/package/posthtml-modules\n\n[deps]: https://david-dm.org/posthtml/posthtml-modules.svg\n[deps-url]: https://david-dm.org/posthtml/posthtml-modules\n\n[style]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg\n[style-url]: https://github.com/sindresorhus/xo\n\n[travis]: http://img.shields.io/travis/posthtml/posthtml-modules.svg\n[travis-url]: https://travis-ci.org/posthtml/posthtml-modules\n\n[cover]: https://coveralls.io/repos/github/posthtml/posthtml-modules/badge.svg?branch=master\n[cover-url]: https://coveralls.io/github/posthtml/posthtml-modules?branch=master\n","funding_links":["https://patreon.com/posthtml","https://opencollective.com/posthtml"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-modules/lists"}