{"id":16720189,"url":"https://github.com/hsynlms/muteferrika","last_synced_at":"2025-03-15T11:40:56.676Z","repository":{"id":57305709,"uuid":"308474701","full_name":"hsynlms/muteferrika","owner":"hsynlms","description":"A simple and lightweight shortcode rendering engine","archived":false,"fork":false,"pushed_at":"2021-05-23T00:27:41.000Z","size":274,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T08:41:13.603Z","etag":null,"topics":["rendering-engine","shortcode","shortcode-engine"],"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/hsynlms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"hsynlms"}},"created_at":"2020-10-29T23:32:53.000Z","updated_at":"2025-01-09T00:13:57.000Z","dependencies_parsed_at":"2022-09-01T13:20:27.847Z","dependency_job_id":null,"html_url":"https://github.com/hsynlms/muteferrika","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/hsynlms%2Fmuteferrika","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsynlms%2Fmuteferrika/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsynlms%2Fmuteferrika/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsynlms%2Fmuteferrika/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hsynlms","download_url":"https://codeload.github.com/hsynlms/muteferrika/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725527,"owners_count":20337666,"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":["rendering-engine","shortcode","shortcode-engine"],"created_at":"2024-10-12T22:06:09.279Z","updated_at":"2025-03-15T11:40:56.661Z","avatar_url":"https://github.com/hsynlms.png","language":"JavaScript","funding_links":["https://github.com/sponsors/hsynlms"],"categories":[],"sub_categories":[],"readme":"# Muteferrika\n\u003e A simple and lightweight shortcode rendering engine.\n\n[![Downloads](https://img.shields.io/npm/dm/muteferrika.svg)](https://npmjs.com/muteferrika)\n[![install size](https://packagephobia.com/badge?p=muteferrika)](https://packagephobia.com/result?p=muteferrika)\n\n`Muteferrika` is a rendering engine with no dependency that gives you full control of how your shortcodes are getting rendered. Create your shortcodes, let Muteferrika know them, and get the rendered output. It's that much simple. It also supports nested shortcodes, yeey!\n\nWheel is not reinvented, instead [Wordpress](https://wordpress.org) shortcode and shortcode attribute parser regular expressions are used in the engine.\n\n## Features\n\n- Supports creating multiple instances\n- Supports self-closing, enclosing and nested shortcodes\n- Supports shortcode attribute parsing with automatic type casting (primitive types)\n- Supports bulk shortcode insert\n- Supports overriding a shortcode callback function at runtime\n- Supports sync and async rendering\n- [Standard](https://github.com/standard/standard) style source code\n- Comprehensive unit tests\n- No dependency!\n\n## Install\n```\n$ npm install muteferrika\n```\n\n## Usage\n\n```js\n// CommonJS syntax\nconst Muteferrika = require('muteferrika')\n\n// ES6 syntax\nimport Muteferrika from 'muteferrika'\n```\n\n## Examples\n\n```js\nconst Muteferrika = require('muteferrika')\n\nconst ibrahim = new Muteferrika()\n\n// define a shortcode\nibrahim.add('entry_image', async (attrs, data) =\u003e {\n  return `\u003cimg src=\"${attrs.src}\" alt=\"${data}\"/\u003e`\n})\n\nconst response =\n  await ibrahim.render('lorem ipsum [entry_image src=\"https://upload.wikimedia.org/wikipedia/commons/a/a2/Ibrahim_M%C3%BCteferrika.jpg\"]Ibrahim Muteferrika[/entry_image] dolor sit amet.')\n\nconsole.log(response)\n\n/*\noutput:\nlorem ipsum \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/a/a2/Ibrahim_M%C3%BCteferrika.jpg\" alt=\"Ibrahim Muteferrika\"/\u003e dolor sit amet\n*/\n```\n\nNested shortcode example:\n\n```js\nconst Muteferrika = require('muteferrika')\n\nconst ibrahim = new Muteferrika()\n\nibrahim.add('parent', (attrs, data) =\u003e {\n  return data\n})\n\nibrahim.add('child', (attrs, data) =\u003e {\n  return 'you said nested?'\n})\n\nconst response = ibrahim.renderSync('[parent]so, [child][/parent]')\n\nconsole.log(response)\n\n/*\noutput:\nso, you said nested?\n*/\n```\n\n## API\n\n### `Muteferrika.add(name, callback)`\n\nAdds given shortcode to the shortcode list to be used in rendering process.\n\n`name` is the unique shortcode name and can contain hyphen(s) and dash(es).\n\n`callback` is the shortcode handler function that renders shortcode and returns the output. The handler function receives (attrs, data). `attrs` is an object that holds all the shortcode attributes, `data` is a string that holds all the content in enclosed/nested shortcodes.\n\n### `Muteferrika.addRange(shortcodes)`\n\nAdds given shortcodes to the shortcode list. Each array item must contain `name` and `callback` properties.\n\n```js\n{\n  name: string,\n  callback: function\n}\n: Array\n```\n\n### `Muteferrika.remove(name)`\n\nRemoves the given shortcode from the shortcode list.\n\n`name` is the unique shortcode name and can contain hyphen(s) and dash(es).\n\n### `Muteferrika.clear()`\n\nClears/removes all shortcodes from the list.\n\n### `Muteferrika.override(name, callback)`\n\nOverrides the shortcode handler function of the given shortcode.\n\n`name` is the unique shortcode name and can contain hyphen(s) and dash(es).\n\n`callback` is the new shortcode handler function.\n\n### `Muteferrika.shortcodes()`\n\nReturns defined shortcodes list.\n\n```js\n{\n  name: string,\n  callback: function\n}\n: Array\n```\n\n### `Muteferrika.render(content)`\n\nAsynchronously renders the shortcodes in the given content through shortcode (sync and async) handler functions.\n\n`content` must be a string.\n\n### `Muteferrika.renderSync(content)`\n\nSynchronously renders the shortcodes in the given content through shortcode (sync and async) handler functions.\n\n`content` must be a string.\n\n### `Muteferrika.on(name, handler)`\n\nSets the handler for the given event.\n\n`name` is the name of the event. See [events section](#events) for more information.\n\n`handler` the event handler function which will be called when the event is fired. See [events section](#events) for more information.\n\n## Events\n\n| Name              | Arguments                                   | Description                                                     |\n| ---               | ---                                         | ---                                                             |\n| tagRender         | `fullMatch` `finalOutput` `shortcodeOutput` | This event will be fired before the shortcode tag is being replaced by the rendered output |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsynlms%2Fmuteferrika","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsynlms%2Fmuteferrika","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsynlms%2Fmuteferrika/lists"}