{"id":22015435,"url":"https://github.com/tsukinoko-kun/yahp","last_synced_at":"2025-03-23T08:44:40.597Z","repository":{"id":40348301,"uuid":"484470487","full_name":"tsukinoko-kun/yahp","owner":"tsukinoko-kun","description":"Yet another HTML preprocessor","archived":false,"fork":false,"pushed_at":"2022-05-27T21:42:10.000Z","size":288,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T19:17:30.307Z","etag":null,"topics":["fetch","html","html-preprocessor","loops","node","preprocessor","transpiler","yet-another"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@frank-mayer/yahp","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/tsukinoko-kun.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":"2022-04-22T14:48:42.000Z","updated_at":"2024-10-23T00:29:58.000Z","dependencies_parsed_at":"2022-08-09T17:50:40.141Z","dependency_job_id":null,"html_url":"https://github.com/tsukinoko-kun/yahp","commit_stats":null,"previous_names":["tsukinoko-kun/yahp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsukinoko-kun%2Fyahp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsukinoko-kun%2Fyahp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsukinoko-kun%2Fyahp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsukinoko-kun%2Fyahp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsukinoko-kun","download_url":"https://codeload.github.com/tsukinoko-kun/yahp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078128,"owners_count":20557279,"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":["fetch","html","html-preprocessor","loops","node","preprocessor","transpiler","yet-another"],"created_at":"2024-11-30T04:21:50.919Z","updated_at":"2025-03-23T08:44:40.568Z","avatar_url":"https://github.com/tsukinoko-kun.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yahp\n\n[![yarn 3](https://shields.io/badge/yarn-PnP-2C8EBB?logo=yarn)](https://yarnpkg.com/features/pnp)\n\nYet another HTML preprocessor (for Node)\n\n## Quickstart Guide\n\n```bash\nyarn add -D @frank-mayer/yahp\n```\n\n```typescript\nimport { yahp } from \"@frank-mayer/yahp\";\nimport fs from \"fs\";\n\nconst input: string = fs.readFileSync(\"./src/index.yahp\", \"utf8\");\nconst output: string = await yahp(input);\nfs.writeFileSync(\"./dist/index.html\", output);\n```\n\n## Features\n\n### Define\n\nDefine block scoped variables.\n\n```html\n\u003cdefine var=\"foo\" value=\"42\"\u003e\n  \u003c!-- variable foo is available here with the value 42 --\u003e\n  \u003cdefine var=\"foo\" value=' \"abc\" '\u003e\n    \u003c!-- variable foo is available here with the value \"abc\" --\u003e\n  \u003c/define\u003e\n  \u003c!-- variable foo is available here with the value 42 --\u003e\n\u003c/define\u003e\n\u003c!-- variable foo is not available anymore  --\u003e\n```\n\n### Eval\n\nRun inline JavaScript Function. Return value is rendered if not undefined.\n\n```html\n\u003cscript eval\u003e\n  const r = Math.random() * 100;\n  return r.toFixed(2);\n\u003c/script\u003e\n```\n\n### Fetch\n\nFetch content using http-get-request.\n\nParse response as JSON.\n\n```html\n\u003cfetch var=\"dog\" as=\"json\" from=\"this.dogDataUrl\"\u003e\n  \u003c!-- ... --\u003e\n\u003c/fetch\u003e\n```\n\nResponse as string.\n\n```html\n\u003cfetch var=\"dog\" as=\"text\" from=\"this.dogNameUrl\"\u003e\n  \u003c!-- ... --\u003e\n\u003c/fetch\u003e\n```\n\nResponse as Data URL\n\n```html\n\u003cfetch var=\"dog\" as=\"dataURL\" from=\"this.dogImgUrl\"\u003e\n  \u003c!-- ... --\u003e\n\u003c/fetch\u003e\n```\n\n### For\n\nIterate using any iterable.\n\n```html\n\u003cfor var=\"item\" of=\"[1,2,3]\"\u003e\n  \u003c!-- ... --\u003e\n\u003c/for\u003e\n```\n\n### If\n\nCheck if a condition is truthy or not.\n\nElse block is not required.\n\n```html\n\u003cif condition=\"Boolean(Math.round(Math.random()))\"\u003e\n  \u003c!-- truthy --\u003e\n\u003c/if\u003e\n\u003celse\u003e\n  \u003c!-- falsy --\u003e\n\u003c/else\u003e\n```\n\n### Import\n\nImport a Module from npm or locally.\n\n```html\n\u003cimport var=\"{ Octokit }\" from=\"@octokit/rest\"\u003e\n  \u003c!-- ... --\u003e\n\u003c/import\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsukinoko-kun%2Fyahp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsukinoko-kun%2Fyahp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsukinoko-kun%2Fyahp/lists"}