{"id":13417367,"url":"https://github.com/fiadone/vite-plugin-twig","last_synced_at":"2026-05-03T12:16:19.000Z","repository":{"id":39547391,"uuid":"443113890","full_name":"fiadone/vite-plugin-twig","owner":"fiadone","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-08T15:43:09.000Z","size":73,"stargazers_count":17,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-17T21:31:17.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/fiadone.png","metadata":{"files":{"readme":"README-v1.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":"2021-12-30T15:30:43.000Z","updated_at":"2024-04-02T01:57:39.000Z","dependencies_parsed_at":"2022-07-13T07:50:57.568Z","dependency_job_id":null,"html_url":"https://github.com/fiadone/vite-plugin-twig","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/fiadone/vite-plugin-twig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiadone%2Fvite-plugin-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiadone%2Fvite-plugin-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiadone%2Fvite-plugin-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiadone%2Fvite-plugin-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiadone","download_url":"https://codeload.github.com/fiadone/vite-plugin-twig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiadone%2Fvite-plugin-twig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32568361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: 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":[],"created_at":"2024-07-30T22:00:35.872Z","updated_at":"2026-05-03T12:16:18.840Z","avatar_url":"https://github.com/fiadone.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# vite-plugin-twig\n\n[Vite](https://github.com/vitejs/vite) plugin for [Twig](https://github.com/twigjs/twig.js/).\n\n---\n\n## ⚠️ Notice\nThis documentation refers to the version *1.x* of the plugin. Take a look [here](./README.md) for latest releases.\n\n\n## Installation\n```\nnpm i -D vite-plugin-twig\n```\n\n\n## Usage\n\n```js\n/* vite.config.js */\nimport { defineConfig } from 'vite'\nimport twig from 'vite-plugin-twig'\n\nexport default defineConfig({\n  // ...\n  plugins: [\n    twig()\n  ]\n})\n```\n\n### Options\nThe plugin can be configured both via the *twig.config.js* file from the project root or by passing a configuration object directly as argument to the function above (in this last case, the configuration file will be ignored).\n\nHere below the list of the supported options.\n\n#### `filters`\n__type__ `{ [key: string]: (...args: any[]) =\u003e any }`\n\n__default__ `{}`\n\nA collection of custom filters to extend *Twig*. Look at [*twig.js* documentation](https://github.com/twigjs/twig.js/wiki/Extending-twig.js) to learn more.\n\n#### `functions`\n__type__ `{ [key: string]: (...args: any[]) =\u003e any }`\n\n__default__ `{}`\n\nA collection of custom functions to extend *Twig*. Look at [*twig.js* documentation](https://github.com/twigjs/twig.js/wiki/Extending-twig.js) to learn more.\n\n#### `globals`\n__type__ `{ [key: string]: any }`\n\n__default__ `{}`\n\nThe global variables to be injected in each template.\n\n#### `settings`\n__type__ `{ [key: string]: any }`\n\n__default__ `{}`\n\nThe *Twig* settings. Please refer to [*twig.js* documentation](https://github.com/twigjs/twig.js/wiki/) to learn more.\n\n\n### Templates\nThe *html* files located by default in the *Vite* project root are not intented to be replaced directly by the *twig* ones as the normal page files resolution/linking on the *Vite*'s dev server is wanted to be preserved along with the build logic. However, those files are supposed to contain a json definition instead of the traditional markup, which should be moved on the *twig* side.\n\nMore in details, a *html* file should look like this:\n\n```html\n\u003c!-- index.html --\u003e\n\u003cscript type=\"application/json\"\u003e\n  {\n    \"template\": \"path/to/template.twig\",\n    \"data\": {\n      \"title\": \"Homepage\"\n    }\n  }\n\u003c/script\u003e\n```\n\nwhere `template` is the path of the *twig* template to be rendered (relative to the *cwd*), and `data` is the local context for that page (eventually merged with the *globals* provided via plugin options).\n\n\u003e ℹ️ The *script* tag is not mandatory, since a plain text representation of the *json* will be correctly parsed too. However, it is recommended for readability and syntax highlighting purposes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiadone%2Fvite-plugin-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiadone%2Fvite-plugin-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiadone%2Fvite-plugin-twig/lists"}