{"id":13669030,"url":"https://github.com/sindresorhus/gulp-template","last_synced_at":"2025-10-18T08:14:33.098Z","repository":{"id":12536914,"uuid":"15206936","full_name":"sindresorhus/gulp-template","owner":"sindresorhus","description":"Render/precompile Lodash templates","archived":false,"fork":false,"pushed_at":"2023-11-01T17:34:16.000Z","size":31,"stargazers_count":287,"open_issues_count":4,"forks_count":78,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-15T02:36:54.322Z","etag":null,"topics":["gulp-plugin","javascript","lodash","nodejs","template","underscore"],"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/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"},"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,"governance":null}},"created_at":"2013-12-15T16:42:04.000Z","updated_at":"2025-04-17T16:24:10.000Z","dependencies_parsed_at":"2023-11-11T11:03:58.800Z","dependency_job_id":"425f2a7f-33a2-4377-8844-9f6daff39d76","html_url":"https://github.com/sindresorhus/gulp-template","commit_stats":{"total_commits":43,"total_committers":8,"mean_commits":5.375,"dds":"0.18604651162790697","last_synced_commit":"1d8d440363550e6e25a946e6cecf5cda28630fb6"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/gulp-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"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":["gulp-plugin","javascript","lodash","nodejs","template","underscore"],"created_at":"2024-08-02T08:00:58.808Z","updated_at":"2025-10-18T08:14:33.094Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Plugins","JavaScript","插件"],"sub_categories":["Templating","模板"],"readme":"# gulp-template\n\n\u003e Render/precompile [Lodash/Underscore templates](https://lodash.com/docs#template)\n\n*Issues with the output should be reported on the Lodash [issue tracker](https://github.com/lodash/lodash/issues).*\n\n## Install\n\n```sh\nnpm install --save-dev gulp-template\n```\n\n## Usage\n\n### `src/greeting.html`\n\n```erb\n\u003ch1\u003eHello \u003c%= name %\u003e\u003c/h1\u003e\n```\n\n### `gulpfile.js`\n\n```js\nimport gulp from 'gulp';\nimport template from 'gulp-template';\n\nexport default () =\u003e (\n\tgulp.src('src/greeting.html')\n\t\t.pipe(template({name: 'Sindre'}))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\nYou can alternatively use [gulp-data](https://github.com/colynb/gulp-data) to inject the data:\n\n```js\nimport gulp from 'gulp';\nimport template from 'gulp-template';\nimport data from 'gulp-data';\n\nexport default () =\u003e (\n\tgulp.src('src/greeting.html')\n\t\t.pipe(data(() =\u003e ({name: 'Sindre'})))\n\t\t.pipe(template())\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n### `dist/greeting.html`\n\n```html\n\u003ch1\u003eHello Sindre\u003c/h1\u003e\n```\n\n## API\n\n### template(data, options?)\n\nRender a template using the provided `data`.\n\n### template.precompile(options?)\n\nPrecompile a template for rendering dynamically at a later time.\n\n#### data\n\nType: `object`\n\nData object used to populate the text.\n\n#### options\n\nType: `object`\n\n[Lodash `_.template` options](https://lodash.com/docs#template).\n\n## Tip\n\nYou can also provide your own [interpolation string](https://lodash.com/docs#template) for custom templates.\n\n### `src/greeting.html`\n\n```html\n\u003ch1\u003eHello {{ name }}\u003c/h1\u003e\n```\n\n### `gulpfile.js`\n\n```js\nimport gulp from 'gulp';\nimport template from 'gulp-template';\nimport data from 'gulp-data';\n\nexport default () =\u003e (\n\tgulp.src('src/greeting.html')\n\t\t.pipe(data(() =\u003e ({name: 'Sindre'})))\n\t\t.pipe(template(null, {\n\t\t\tinterpolate: /{{(.+?)}}/gs\n\t\t}))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n### `dist/greeting.html`\n\n```html\n\u003ch1\u003eHello Sindre\u003c/h1\u003e\n```\n\n## Tip\n\nIf you need to pass through a file unprocessed (for example, a shell script with `${VAR}` syntax), you can disable interpolation:\n\n```js\n.pipe(template(data, {interpolate: false}))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fgulp-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-template/lists"}