{"id":19039083,"url":"https://github.com/ramasilveyra/templatize-css","last_synced_at":"2025-04-23T20:11:38.893Z","repository":{"id":39042694,"uuid":"143887467","full_name":"ramasilveyra/templatize-css","owner":"ramasilveyra","description":"Templatize CSS files","archived":false,"fork":false,"pushed_at":"2022-12-10T03:19:53.000Z","size":901,"stargazers_count":4,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T20:11:33.632Z","etag":null,"topics":["css","cssnext","postcss","templates"],"latest_commit_sha":null,"homepage":null,"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/ramasilveyra.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-07T14:46:06.000Z","updated_at":"2023-03-24T05:44:04.000Z","dependencies_parsed_at":"2023-01-26T02:16:54.585Z","dependency_job_id":null,"html_url":"https://github.com/ramasilveyra/templatize-css","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramasilveyra%2Ftemplatize-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramasilveyra%2Ftemplatize-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramasilveyra%2Ftemplatize-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramasilveyra%2Ftemplatize-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramasilveyra","download_url":"https://codeload.github.com/ramasilveyra/templatize-css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506141,"owners_count":21441723,"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":["css","cssnext","postcss","templates"],"created_at":"2024-11-08T22:11:49.223Z","updated_at":"2025-04-23T20:11:38.835Z","avatar_url":"https://github.com/ramasilveyra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/templatize-css\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/templatize-css.svg?maxAge=86400\" alt=\"Last npm Registry Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/ramasilveyra/templatize-css?branch=master\"\u003e\n    \u003cimg src=\"https://travis-ci.org/ramasilveyra/templatize-css.svg?branch=master\" alt=\"Build Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/github/ramasilveyra/templatize-css?branch=master\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/ramasilveyra/templatize-css.svg?branch=master\" alt=\"Code coverage\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003eTemplatize CSS files\u003c/h1\u003e\n\n\u003e Do you want to generate dynamic CSS and you can't use CSS in JS?\n\n\u003ch3 align=\"center\"\u003eInput\u003c/h3\u003e\n\n```css\n:root {\n  --main-primary-color: brown; /* templatize-css: track */\n  --main-mobile-primary-color: brown; /* templatize-css: track */\n  --main-text-color: #fff; /* templatize-css: track */\n  --main-link-color: #000;\n}\n\n.btn {\n  background-color: var(--main-primary-color);\n  color: var(--main-text-color);\n  border: 0;\n  padding: 10px 40px;\n}\n\n.btn-link {\n  background-color: var(--main-link-color);\n  border: 0;\n  padding: 10px 40px;\n}\n\n@media (min-width: 992px) {\n  .btn::after {\n    background-color: var(--main-mobile-primary-color);\n    padding: 5px 10px;\n  }\n}\n```\n\n\u003ch3 align=\"center\"\u003eOutput\u003c/h3\u003e\n\n```js\nconst defaults = {\n  mainPrimaryColor: 'brown',\n  mainMobilePrimaryColor: 'brown',\n  mainTextColor: '#fff'\n};\n\nconst templatize = locals =\u003e `.btn {\n  background-color: ${locals.mainPrimaryColor || defaults.mainPrimaryColor};\n  color: ${locals.mainTextColor || defaults.mainTextColor}\n}\n@media (min-width: 992px) {\n  .btn::after {\n    background-color: ${locals.mainMobilePrimaryColor || defaults.mainMobilePrimaryColor}\n  }\n}`;\n\nmodule.exports = { defaults, templatize };\n```\n\n\u003ch2 align=\"center\"\u003eTable of Contents\u003c/h2\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n- [Contribute](#contribute)\n- [License](#license)\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n**Node.js v8 or newer** is required.\n\nVia the yarn client:\n\n```bash\n$ yarn add --dev templatize-css\n```\n\nVia the npm client:\n\n```bash\n$ npm install --save-dev templatize-css\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n\u003ch3 align=\"center\"\u003eAPI\u003c/h3\u003e\n\n#### Compile\n\n```js\nimport { compile } from 'templatize-css';\n\nconst css = `:root {\n  --main-bg-color: brown; /* templatize-css: track */\n}\n\n.btn {\n  background-color: var(--main-bg-color);\n}\n`;\n\nconst template = compile(css);\n```\n\n#### Compile File\n\n```js\nimport path from 'path';\nimport { compileFile } from 'templatize-css';\n\nconst cssFilePath = path.resolve(__dirname, 'input.css');\nconst templateFilePath = path.resolve(__dirname, 'template.js');\n\ncompileFile(cssFilePath, templateFilePath).then(() =\u003e {\n  console.log('File Compiled! 🍕');\n});\n```\n\n\u003ch3 align=\"center\"\u003eCLI\u003c/h3\u003e\n\n#### Compile File (`--out-file`/`-o`)\n\n```bash\ntemplatize-css src/main.css --out-file src/template-main-css.js\n```\n\n\u003ch2 align=\"center\"\u003eContribute\u003c/h2\u003e\n\nFeel free to dive in! [Open an issue](https://github.com/ramasilveyra/templatize-css/issues/new) or submit PRs.\n\ntemplatize-css follows the [Contributor Covenant](https://contributor-covenant.org/version/1/4/) Code of Conduct.\n\n\u003ch2 align=\"center\"\u003eLicense\u003c/h2\u003e\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framasilveyra%2Ftemplatize-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framasilveyra%2Ftemplatize-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framasilveyra%2Ftemplatize-css/lists"}