{"id":22799971,"url":"https://github.com/dadi/web-es6-templates","last_synced_at":"2025-10-05T13:26:27.656Z","repository":{"id":57105384,"uuid":"99256210","full_name":"dadi/web-es6-templates","owner":"dadi","description":"A ES6 template literals interface for DADI Web","archived":false,"fork":false,"pushed_at":"2019-05-03T15:00:50.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T03:48:55.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dadi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-03T17:00:30.000Z","updated_at":"2019-05-03T15:00:50.000Z","dependencies_parsed_at":"2022-08-20T20:10:40.518Z","dependency_job_id":null,"html_url":"https://github.com/dadi/web-es6-templates","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dadi%2Fweb-es6-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dadi%2Fweb-es6-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dadi%2Fweb-es6-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dadi%2Fweb-es6-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dadi","download_url":"https://codeload.github.com/dadi/web-es6-templates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365644,"owners_count":20765549,"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":"2024-12-12T07:10:39.076Z","updated_at":"2025-10-05T13:26:22.614Z","avatar_url":"https://github.com/dadi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://dadi.cloud/assets/products/dadi-web-full.png\" alt=\"DADI Web\" height=\"65\"/\u003e\n\n## ES6 template engine interface\n\n[![npm (scoped)](https://img.shields.io/npm/v/@dadi/web-es6-templates.svg?maxAge=10800\u0026style=flat-square)](https://www.npmjs.com/package/@dadi/web-es6-templates)\n[![Coverage Status](https://coveralls.io/repos/github/dadi/web-es6-templates/badge.svg?branch=master)](https://coveralls.io/github/dadi/web-es6-templates?branch=master)\n[![Build Status](https://travis-ci.org/dadi/web-es6-templates.svg?branch=master)](https://travis-ci.org/dadi/web-es6-templates)\n[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n\nThis module allows native [ES6 template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals) to be used with [DADI Web](https://github.com/dadi/web).\n\n## Installation\n\n- Add this module as a dependency:\n\n   ```\n   npm install @dadi/web-es6-templates --save\n   ```\n\n- Include it in the `engines` array passed to Web:\n\n   ```js\n   require('@dadi/web')({\n     engines: [\n       require('@dadi/web-es6-templates')\n     ]\n   })\n   ```\n\n## Usage\n\n### Helpers\n\nThe base directory for absolute paths is the `utils/helpers` directory.\n\nHelpers are `required()` functions that can be embeded into templates to keep your code DRY. Take this example which could live in your `helpers` folder as `slugify.js`.\n\n```javascript\nvar s = require('underscore.string/slugify')\n\nmodule.exports = slugify = (chunk) =\u003e {\n  return s(chunk)\n}\n```\n\nThis function would be used in a template file like so:\n\n```javascript\n${slugify('The Quick Brown Fox Jumps Over The Lazy Dog')}\n```\n\nOutput:\n\n```\nthe-quick-brown-fox-jumps-over-the-lazy-dog\n```\n\n### Includes\n\nThe base directory for absolute paths is the `pages/` directory. Take the following directory tree.\n\n```\npages/\n|_ partials/\n|_ |_ header.js\n|_ |_ footer.js\n|_ index.js\n|_ index.json\n```\n\nTo include the partials from `index.js`, you can use an underscore to indicate a sub-folder:\n\n```js\n${partials_header}\n\n\u003ch1\u003eES6 Templates test\u003c/h1\u003e\n\n\u003cp\u003eThis page lives at ${host}.\u003c/p\u003e\n\n\u003ch2\u003eLoop test\u003c/h2\u003e\n\n\u003cul\u003e\n  ${posts.results.map(i =\u003e '\u003cli\u003e' + i.attributes.title + '\u003c/li\u003e').join('')}\n\u003c/ul\u003e\n\n${partials_footer}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdadi%2Fweb-es6-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdadi%2Fweb-es6-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdadi%2Fweb-es6-templates/lists"}