{"id":24983686,"url":"https://github.com/posthtml/posthtml-include","last_synced_at":"2025-04-12T22:34:28.596Z","repository":{"id":1611633,"uuid":"42880995","full_name":"posthtml/posthtml-include","owner":"posthtml","description":"Include HTML Plugin","archived":false,"fork":false,"pushed_at":"2024-08-29T19:33:12.000Z","size":1738,"stargazers_count":199,"open_issues_count":8,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T14:07:48.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":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":"2015-09-21T17:06:26.000Z","updated_at":"2025-04-01T23:24:20.000Z","dependencies_parsed_at":"2024-11-07T20:22:31.686Z","dependency_job_id":"64680c90-a64d-43c1-b02b-e7f284cfcb27","html_url":"https://github.com/posthtml/posthtml-include","commit_stats":{"total_commits":134,"total_committers":22,"mean_commits":6.090909090909091,"dds":0.5074626865671642,"last_synced_commit":"8f5da6627d04c56cdd066e43f7e86c2176b2448a"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-include","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-include/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-include/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-include/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-include/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248640807,"owners_count":21138097,"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.690Z","updated_at":"2025-04-12T22:34:28.571Z","avatar_url":"https://github.com/posthtml.png","language":"HTML","readme":"[![Actions Status][action]][action-url]\n[![NPM][npm]][npm-url]\n[![Coverage][cover]][cover-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\u003eInclude Plugin\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm i -D posthtml-include\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n```js\nconst { readFileSync } = require('fs')\n\nconst posthtml = require('posthtml')\nconst include = require('posthtml-include')\n\nconst html = readFileSync('index.html')\n\nposthtml([ include({ encoding: 'utf8' }) ])\n    .process(html)\n    .then((result) =\u003e console.log(result.html))\n```\n\n### Options\n\n__root__: Root directory for include. Default `process.cwd()`\n\n__cwd__: Current working directory for include. Default `process.cwd()`\n\n__encoding__: Default `utf-8`\n\n__posthtmlExpressionsOptions__: Array to pass options posthtml-expression\n\n### Component options\n__locals__: Object containing any local variables that you want to be accessible inside the include component\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n__index.html__\n\n```html\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eindex.html\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cinclude src=\"components/button.html\" locals='{\n        \"text\": \"Button\"\n    }'\u003e\u003c/include\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n__components/button.html__\n```html\n\u003cbutton class=\"button\"\u003e\u003cdiv class=\"button__text\"\u003e{{ text }}\u003c/div\u003e\u003c/button\u003e\n```\n\n```js\nconst { readFileSync } = require('fs')\n\nconst posthtml = require('posthtml')\nconst include = require('posthtml-include')\n\nconst html = readFileSync('index.html')\n\nposthtml([ include({ encoding: 'utf8' }) ])\n    .process(html)\n    .then((result) =\u003e console.log(result.html))\n```\n\n```html\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eindex.html\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cbutton class=\"button\"\u003e\n    \u003cdiv class=\"button__text\"\u003eButton\u003c/div\u003e\n  \u003c/button\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nYou can also pass your locals directly on the \\\u003cinclude\u003e content, just drop a JSON there. When doing it, all the \"\\n\" chars will be removed from your data.\nIf you need \"\\n\" chars on your data, you can still use the \"locals\" attribute.\n\n```html\n\u003cinclude src=\"components/button.html\"\u003e\n  {\n    \"text\": \"Button\"\n  }\n\u003c/include\u003e\n```\n\n\u003e **Note:** Also supports multi nesting.\n\n\u003ch2 align=\"center\"\u003eLICENSE\u003c/h2\u003e\n\n\u003e MIT License (MIT)\n\n\u003e Copyright (c) PostHTML Ivan Voischev\n\n\u003e Permission 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\n\u003e The above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\n\u003e THE 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[action]: https://github.com/posthtml/posthtml-include/workflows/Actions%20Status/badge.svg?style=flat-square\n[action-url]: https://github.com/posthtml/posthtml-include/actions?query=workflow%3A%22CI+tests%22\n\n[npm]: https://img.shields.io/npm/v/posthtml-include.svg\n[npm-url]: https://npmjs.com/package/posthtml-include\n\n[cover]: https://coveralls.io/repos/github/posthtml/posthtml-include/badge.svg?branch=master\n[cover-url]: https://coveralls.io/github/posthtml/posthtml-include?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-include","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-include","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-include/lists"}