{"id":18432126,"url":"https://github.com/dustinspecker/dscript","last_synced_at":"2025-09-24T03:32:27.542Z","repository":{"id":57216727,"uuid":"51490134","full_name":"dustinspecker/dscript","owner":"dustinspecker","description":"Framework agnostic hyperscript","archived":false,"fork":false,"pushed_at":"2017-05-28T20:11:41.000Z","size":38,"stargazers_count":35,"open_issues_count":21,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-28T10:39:06.544Z","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/dustinspecker.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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":"2016-02-11T02:45:08.000Z","updated_at":"2020-11-01T04:39:30.000Z","dependencies_parsed_at":"2022-08-26T12:50:13.229Z","dependency_job_id":null,"html_url":"https://github.com/dustinspecker/dscript","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinspecker%2Fdscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinspecker%2Fdscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinspecker%2Fdscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinspecker%2Fdscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dustinspecker","download_url":"https://codeload.github.com/dustinspecker/dscript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234032769,"owners_count":18769099,"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-06T05:27:30.813Z","updated_at":"2025-09-24T03:32:27.117Z","avatar_url":"https://github.com/dustinspecker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dscript\n[![NPM version](https://badge.fury.io/js/dscript.svg)](https://badge.fury.io/js/dscript)\n[![Build Status](https://travis-ci.org/dustinspecker/dscript.svg)](https://travis-ci.org/dustinspecker/dscript)\n[![Coverage Status](https://img.shields.io/coveralls/dustinspecker/dscript.svg)](https://coveralls.io/r/dustinspecker/dscript?branch=master)\n\n[![Code Climate](https://codeclimate.com/github/dustinspecker/dscript/badges/gpa.svg)](https://codeclimate.com/github/dustinspecker/dscript)\n[![Dependencies](https://david-dm.org/dustinspecker/dscript.svg)](https://david-dm.org/dustinspecker/dscript/#info=dependencies\u0026view=table)\n[![DevDependencies](https://david-dm.org/dustinspecker/dscript/dev-status.svg)](https://david-dm.org/dustinspecker/dscript/#info=devDependencies\u0026view=table)\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n\u003e Framework agnostic hyperscript\n\n\u003e Should work with any JSX pragma that works out of the box with Babel's JSX implementation or a function that accepts an HTML tag or component, attributes object, and children list.\n\n## Install\n```\nnpm install --save dscript\n```\n\n**Note: Webpack users will need to setup a [json-loader](https://github.com/webpack/json-loader) as dscript relies on [html-tags](https://github.com/sindresorhus/html-tags), which uses a [JSON file](https://github.com/sindresorhus/html-tags/blob/master/html-tags.json)**\n\n## General Usage\n```javascript\nimport dscript from 'dscript'\nimport {element} from 'deku'\n\nconst {div, li, ul} = dscript(element)\n\nconst handleClick = () =\u003e alert('hi!')\n\nexport default ({props}) =\u003e\n  div('.list-container', {onClick: handleClick}, [\n    ul(\n      props.items.map(item =\u003e\n        li(item.name)\n      )\n    )\n  ])\n```\n\n## Usage with React\n**It is recommended to use [dscript-react](https://github.com/dustinspecker/dscript-react) to remove dscript boilerplate.**\n\nTake the following:\n```javascript\nimport React from 'react'\n\nexport default props =\u003e\n  \u003cul\u003e\n    {props.items.map(item =\u003e\n      \u003cli\u003e{item.name}\u003c/li\u003e\n    )}\n  \u003c/ul\u003e\n```\nor:\n```javascript\nimport {createElement} from 'react'\n\nexport default props =\u003e\n  createElement('ul', {},\n    props.items.map(item =\u003e\n      createElement('li', {}, [\n        item.name\n      ])\n    )\n  )\n```\n\nand instead write:\n\n```javascript\nimport {createElement} from 'react'\nimport dscript from 'dscript'\n\nconst {li, ul} = dscript(createElement)\n\nexport default props =\u003e\n  ul(\n    props.items.map(item =\u003e\n      li(item.name)\n    )\n  )\n\n```\n\n## Usage with Deku\n**It is recommended to use [dscript-deku](https://github.com/dustinspecker/dscript-deku) to remove dscript boilerplate.**\n\nTake the following:\n```javascript\nimport {element} from 'deku'\n\nexport default ({props}) =\u003e\n  \u003cul\u003e\n    {props.items.map(item =\u003e\n      \u003cli\u003e{item.name}\u003c/li\u003e\n    }\n  \u003c/ul\u003e\n```\n\nor:\n\n```javascript\nimport {element} from 'deku'\n\nexport default ({props}) =\u003e\n  element('ul', {},\n    props.items.map(item =\u003e\n      element('li', {}, [\n        item.name\n      ])\n    )\n  )\n```\n\nand instead write:\n```javascript\nimport dscript from 'dscript'\nimport {element} from 'deku'\n\nconst {li, ul} = dscript(element)\n\nexport default ({props}) =\u003e\n  ul(\n    props.items.map(item =\u003e\n      li(item.name)\n    )\n  )\n```\n\n## Usage with Custom Components\nCustom components example is shown using React, but works with any framework that works with dscript's basic functionality.\n\n```javascript\nimport dscript from 'dscript'\nimport {createElement} from 'react'\n\nimport customComponent from './custom-component'\n\nconst creator = dscript(createElement)\n\nconst {div, li, ul} = creator\nconst customComponentCreator = creator(customComponent)\n\nconst handleClick = () =\u003e alert('hi!')\n\nexport default props =\u003e\n  div('.list-container', {onClick: handleClick}, [\n    customComponentCreator({total: props.total}),\n    ul(\n      props.items.map(item =\u003e\n        li(item.name)\n      )\n    )\n  ])\n```\n\n## API\n### dscript(createElement)\nReturns an object with properties consisting of HTML tags with values being [creator functions](#creator-functions).\n\n#### createElement\ntype: `function`\n\nA function to use to create the Virtual DOM. For example, React's `createElement` or Deku's `element`.\n\n### dscript(createElement)(customComponent)\n\nReturns a [creator function](#creator-functions) to be used in dscript.\n\nFor example:\n\n```javascript\nimport {createElement} from 'react'\nimport customComponent from './lib/custom-react-component/'\nimport dscript from 'dscript'\n\nconst creator = dscript(createElement)\n\nconst {div} = creator\nconst custom = creator(customComponent)\n\nexport default div([custom()])\n```\n\n#### createElement\n\nSame as above\n\n#### customComponent\n\ntype: `any`\n\nShould be a valid component for the `createElement` function.\n\n\n### Creator Functions\n`creatorFunction([cssClassesAndOrIdSelector,] [attributes,] [children])`\n\nA function that returns a virtual DOM node created with `createElement`.\n\n#### cssClassesAndOrIdSelector\ntype: `string`\n\ndefault: `null`\n\nA convenience to add class names and an id to a virtual DOM node. **Note: The provided selector will override `attribute`'s class and id.**\n\n### attributes\ntype: `object`\n\ndefault: `{}`\n\nAn object that will be passed as the attributes to the virutal DOM node.\n\n### children\ntype: `...Elements`\n\ndefault: `[]`\n\nThe list of children passed to the created virtual DOM node.\n\n## LICENSE\nMIT © [Dustin Specker](https://github.com/dustinspecker)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinspecker%2Fdscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdustinspecker%2Fdscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinspecker%2Fdscript/lists"}