{"id":21074782,"url":"https://github.com/dawsbot/duplival","last_synced_at":"2026-04-21T21:35:55.323Z","repository":{"id":57217207,"uuid":"53470995","full_name":"dawsbot/duplival","owner":"dawsbot","description":"JSON + variables === \u003c3  in only 292 bytes","archived":false,"fork":false,"pushed_at":"2016-07-01T04:41:59.000Z","size":9,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T06:45:27.656Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dawsbot.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-09T05:32:58.000Z","updated_at":"2016-07-11T04:12:52.000Z","dependencies_parsed_at":"2022-08-28T21:40:20.200Z","dependency_job_id":null,"html_url":"https://github.com/dawsbot/duplival","commit_stats":null,"previous_names":["dawsonbotsford/duplival"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fduplival","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fduplival/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fduplival/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fduplival/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawsbot","download_url":"https://codeload.github.com/dawsbot/duplival/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243517454,"owners_count":20303632,"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-11-19T19:17:56.293Z","updated_at":"2025-12-29T21:46:35.212Z","avatar_url":"https://github.com/dawsbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# duplival\n[![npm version](https://img.shields.io/npm/v/duplival.svg)](https://www.npmjs.com/package/duplival)\n[![Build Status](https://travis-ci.org/dawsonbotsford/duplival.svg?branch=master)](https://travis-ci.org/dawsonbotsford/duplival)\n[![npm download count](http://img.shields.io/npm/dm/duplival.svg?style=flat)](http://npmjs.org/duplival)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\n\u003e JSON + variables === \u003c3 in only 292 bytes\n\n\u003cbr\u003e\n\n## Usage\n\n```js\nconst duplival = require('duplival');\n\nduplival({\n  key1: 'value1',\n  key2: '\u003c%= key1 %\u003e'\n});\n/*\n{\n  key1: 'value1',\n  key2: 'value1'\n};\n*/\n```\n\n\u003cbr\u003e\n\n## Install\n\n```\nnpm install --save duplival\n```\n\n\u003cbr\u003e\n\n## Advanced Example\n```js\nconst duplival = require('duplival');\n\nduplival({\n  key1: 1,\n  key2: '\u003c%= key1 %\u003e',\n  key3: '\u003c%= key1 + 2 %\u003e'\n});\n/*\n{\n  key1: 1,\n  key2: '1',\n  key3: '3'\n};\n*/\n\n\nconst piglatin = require('piglatin');\n\nconst piglatinTemplate = {\n  translate: piglatin,\n  englishSentence: 'This is a very very long string you would not want to duplicate or type out. Yet you do want to do some type of operation with it. Let\\'s say for example that you want to translate this. With english as your base and pig-latin as your goal, let\\'s have some fun',\n  piglatinSentence: `\u003c%= translate(englishSentence) %\u003e`\n};\nduplival(piglatinTemplate).piglatinSentence;\n/*\n'histay is a eryvay eryvay onglay tringsay ouyay ouldway otnay antway to uplicateday or ypetay utoay etyay ouyay do antway to do omesay ypetay of perationoay ithway it etlay s aysay orfay xampleeay hattay ouyay antway to ranslatetay histay ithway nglisheay as ouryay asebay ndaay igpay atinlay as ouryay oalgay etlay s avehay omesay unfay';\n*/\n```\n\n\u003cbr\u003e\n\n#### How did that just happen?\n\n`duplival` is powered by mighty [ejs templating](http://ejs.co/). Although originally intended for html, ejs can easily be hijacked into being our engine. It means we can now use variables, conditionals, and even loops inside of JSON objects.\n\n\u003cbr\u003e\n\n## API\n\n### duplival(target)\n\n##### target\n\nType: `object`\n\nPowered by [ejs](http://ejs.co/)'s powerful templating, this **tiny module** can help reduce code duplication create smaller JSON objects in your code.\n\n\u003cbr\u003e\n\n## License\n\nMIT © [Dawson Botsford](http://dawsonbotsford.com)\n\n\u003cbr\u003e\n\n---\nIf you like this, star it. If you want to follow me, follow me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fduplival","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawsbot%2Fduplival","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fduplival/lists"}