{"id":13991607,"url":"https://github.com/jstransformers/jstransformer","last_synced_at":"2025-05-16T08:04:50.740Z","repository":{"id":23456764,"uuid":"26820697","full_name":"jstransformers/jstransformer","owner":"jstransformers","description":"Normalize the API of any JSTransformer.","archived":false,"fork":false,"pushed_at":"2023-06-29T08:46:17.000Z","size":128,"stargazers_count":152,"open_issues_count":86,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-11T08:49:00.416Z","etag":null,"topics":["asynchronously","consolidate","engine","javascript","jstransformer","promise","templates","transform","unified"],"latest_commit_sha":null,"homepage":"http://npm.im/jstransformer","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/jstransformers.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-18T17:18:37.000Z","updated_at":"2024-08-08T15:17:34.000Z","dependencies_parsed_at":"2024-06-18T12:38:11.790Z","dependency_job_id":"6bc87fe7-deff-4177-ab5b-b8a26ae94485","html_url":"https://github.com/jstransformers/jstransformer","commit_stats":{"total_commits":126,"total_committers":13,"mean_commits":9.692307692307692,"dds":0.4365079365079365,"last_synced_commit":"59f2b02003674a3cabba26c2dca720446e617cf4"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jstransformers%2Fjstransformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jstransformers%2Fjstransformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jstransformers%2Fjstransformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jstransformers%2Fjstransformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jstransformers","download_url":"https://codeload.github.com/jstransformers/jstransformer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"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":["asynchronously","consolidate","engine","javascript","jstransformer","promise","templates","transform","unified"],"created_at":"2024-08-09T14:01:29.019Z","updated_at":"2025-05-16T08:04:45.725Z","avatar_url":"https://github.com/jstransformers.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","javascript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"logo/logo.svg\" align=\"right\"  width=\"300px\" height=\"299px\"\u003e\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eJSTransformer\u003c/h1\u003e\n\u003cp align=\"center\"\u003eNormalize the API of any jstransformer\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://travis-ci.org/jstransformers/jstransformer\"\u003e\u003cimg src=\"https://img.shields.io/travis/jstransformers/jstransformer/master.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://david-dm.org/jstransformers/jstransformer\"\u003e\u003cimg src=\"https://img.shields.io/david/jstransformers/jstransformer.svg\" alt=\"Dependency Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://david-dm.org/jstransformers/jstransformer#info=devDependencies\"\u003e\u003cimg src=\"https://img.shields.io/david/dev/jstransformers/jstransformer.svg\" alt=\"Developers' Dependency Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/r/jstransformers/jstransformer?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/jstransformers/jstransformer/master.svg\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.org/package/jstransformer\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/jstransformer.svg\" alt=\"NPM version\"\u003e\u003c/a\u003e\u003c/p\u003e\n\nThere are many good template engines and compilers written for Node.js. But there is a problem: all of them have slightly different APIs, requiring slightly different usage. JSTransformer unifies them into one standardized API. Code written for one transformer will work with any other transformer. There are [over 100 transformers](https://www.npmjs.com/browse/keyword/jstransformer), ranging from Markdown parsers to template engines to code compilers.\n\n## Installation\n\n    npm install jstransformer\n\n## Usage\n\n```js\nvar transformer = require('jstransformer');\nvar marked = transformer(require('jstransformer-marked'));\n\nvar options = {};\nvar res = marked.render('Some **markdown**', options);\n// =\u003e {body: 'Some \u003cstrong\u003emarkdown\u003c/strong\u003e', dependencies: []}\n```\n\nThis gives the same API regardless of the jstransformer passed in.\n\n## API\n\nA transformer, once normalised using this module, will implement the following methods.  Note that if the underlying transformer cannot be used to implement the functionality, it may ultimately just throw an error.\n\n### `.render*`\n\n#### Returned object from `.render*`\n\n```js\n{body: String, dependencies: Array.\u003cString\u003e}\n```\n\n - `body` represents the result as a string\n - `dependencies` is an array of file names that were read in as part of the render process (or an empty array if there were no dependencies)\n\n#### `.render`\n\n```js\ntransformer.render(str, options, locals);\n=\u003e {body: String, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.render` or `.compile`_\n\nTransform a string and return an object.\n\n#### `.renderAsync`\n\n```js\ntransformer.renderAsync(str[, options], locals, callback);\n```\n\n```js\ntransformer.renderAsync(str[, options], locals);\n=\u003e Promise({body: String, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.renderAsync`, `.render`, `.compile`, or `.compileAsync`_\n\nTransform a string asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n#### `.renderFile`\n\n```js\ntransformer.renderFile(filename, options, locals)\n=\u003e {body: String, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.renderFile`, `.render`, `.compileFile`, or `.compile`_\n\nTransform a file and return an object.\n\n#### `.renderFileAsync`\n\n```js\ntransformer.renderFileAsync(filename[, options], locals, callback);\n```\n\n```js\ntransformer.renderFileAsync(filename[, options], locals);\n=\u003e Promise({body: String, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.renderFileAsync`, `.renderFile`, `.renderAsync`, `.render`, `.compileFileAsync`, `.compileFile`, `.compileAsync`, or `.compile`_\n\nTransform a file asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n### `.compile*`\n\n#### Returned object from `.compile*`\n\n```js\n{fn: Function, dependencies: Array.\u003cString\u003e}\n```\n\n - `fn` is a function that takes a locals object and returns the rendered template as a string.\n - `dependencies` is an array of file names that were read in as part of the compilation process (or an empty array if there were no dependencies)\n\n#### `.compile`\n\n```js\ntransformer.compile(str[, options]);\n=\u003e {fn: Function, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.compile` or `.render`_\n\nCompile a string and return an object.\n\n#### `.compileAsync`\n\n```js\ntransformer.compileAsync(str[, options], callback);\n```\n\n```js\ntransformer.compileAsync(str[, options]);\n=\u003e Promise({fn: Function, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.compileAsync`, `.compile` or `.render`_\n\nCompile a string asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n#### `.compileFile`\n\n```js\ntransformer.compileFile(filename[, options])\n=\u003e {fn: Function, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.compileFile`, `.compile`, `.renderFile`, or `.render`_\n\nCompile a file and return an object.\n\n#### `.compileFileAsync`\n\n```js\ntransformer.compileFileAsync(filename[, options], callback);\n```\n\n```js\ntransformer.compileFileAsync(filename[, options]);\n=\u003e Promise({fn: Function, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.compileFileAsync`, `.compileFile`, `.compileAsync`, `.compile`, `.renderFileAsync`, `.renderFile`, or `.render`_\n\nCompile a file asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n### `.compileClient*`\n\n#### Returned object from `.compileClient*`\n\n```js\n{body: String, dependencies: Array.\u003cString\u003e}\n```\n\n - `body` is a `.toString`ed function that can be used on the client side.\n - `dependencies` is an array of file names that were read in as part of the compilation process (or an empty array if there were no dependencies)\n\n#### `.compileClient`\n\n```js\ntransformer.compileClient(str[, options]);\n=\u003e {body: String, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.compileClient`_\n\nCompile a string for client-side use and return an object.\n\n#### `.compileClientAsync`\n\n```js\ntransformer.compileClientAsync(str[, options], callback);\n```\n\n```js\ntransformer.compileClientAsync(str[, options]);\n=\u003e Promise({body: String, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.compileClientAsync` or `.compileClient`_\n\nCompile a string for client-side use asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n#### `.compileFileClient`\n\n```js\ntransformer.compileFileClient(filename[, options])\n=\u003e {body: String, dependencies: Array.\u003cString\u003e}\n```\n\n_requires the underlying transform to implement `.compileFileClient` or `.compileClient`_\n\nCompile a file for client-side use and return an object.\n\n#### `.compileFileClientAsync`\n\n```js\ntransformer.compileFileClientAsync(filename[, options], callback);\n```\n\n```js\ntransformer.compileFileClientAsync(filename[, options]);\n=\u003e Promise({body: String, dependencies: Array.\u003cString\u003e})\n```\n\n_requires the underlying transform to implement `.compileFileClientAsync`, `.compileFileClient`, `.compileClientAsync`, or `.compileClient`_\n\nCompile a file for client-side use asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.\n\n### `.inputFormats`\n\n```js\nvar formats = transformer.inputFormats;\n=\u003e ['md', 'markdown']\n```\n\nReturns an array of strings representing potential input formats for the transform. If not provided directly by the transform, results in an array containing the name of the transform.\n\n### `.outputFormat`\n\n```js\nvar md = require('jstransformer')(require('jstransformer-markdown'))\nvar outputFormat = md.outputFormat\n=\u003e 'html'\n```\n\nReturns a string representing the default output format the transform would be expected to return when calling `.render()`.\n\n### `.can`\n\n```js\nvar md = require('jstransformer')(require('jstransformer-markdown'))\nmd.can('render');\n=\u003e true\n```\n\nTakes a method name as a string and returns a boolean value indicating whether the normalised transform implements this method.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjstransformers%2Fjstransformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjstransformers%2Fjstransformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjstransformers%2Fjstransformer/lists"}