{"id":21540967,"url":"https://github.com/reshape/standard","last_synced_at":"2025-04-10T04:11:21.607Z","repository":{"id":57354544,"uuid":"67167441","full_name":"reshape/standard","owner":"reshape","description":"a standard plugin pack with modern template language features","archived":false,"fork":false,"pushed_at":"2019-02-05T12:47:51.000Z","size":535,"stargazers_count":17,"open_issues_count":9,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-27T03:42:51.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reshape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","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-09-01T21:24:47.000Z","updated_at":"2018-09-25T02:30:55.000Z","dependencies_parsed_at":"2022-09-12T03:20:43.399Z","dependency_job_id":null,"html_url":"https://github.com/reshape/standard","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reshape%2Fstandard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reshape%2Fstandard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reshape%2Fstandard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reshape%2Fstandard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reshape","download_url":"https://codeload.github.com/reshape/standard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154990,"owners_count":21056543,"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-24T05:00:46.140Z","updated_at":"2025-04-10T04:11:21.581Z","avatar_url":"https://github.com/reshape.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reshape Standard Preset\n\n[![npm](http://img.shields.io/npm/v/reshape-standard.svg?style=flat-square)](https://badge.fury.io/js/reshape-standard) [![tests](http://img.shields.io/travis/reshape/standard/master.svg?style=flat-square)](https://travis-ci.org/reshape/standard) [![dependencies](http://img.shields.io/david/reshape/standard.svg?style=flat-square)](https://david-dm.org/reshape/standard)\n[![coverage](https://img.shields.io/codecov/c/github/reshape/standard.svg?style=flat-square)](https://codecov.io/gh/reshape/standard)\n\nA standard, opinionated preset for reshape\n\n\u003e **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.\n\n### Installation\n\n`npm install reshape-standard -S`\n\n\u003e **Note:** This project is compatible with node v6+ only\n\n### Example\n\nThe standard preset includes plugins that cover all the features needed from a modern template engine. Below is an example of a page utilizing many of the features:\n\n```\n\u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eStandard Example\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello world!\u003c/h1\u003e\n\n    \u003cul id='nav'\u003e\n      \u003cli class='active'\u003e\u003ca href='#'\u003ehome\u003c/a\u003e\u003c/li\u003e\n      \u003cli\u003e\u003ca href='#'\u003eabout\u003c/a\u003e\u003c/li\u003e\n    \u003c/ul\u003e\n\n    \u003cinclude src='_welcome_message.sgr'\u003e\u003c/include\u003e\n\n    \u003cp\u003elocal variable: {{ foo }}\u003c/p\u003e\n\n    \u003ceach loop='item of items'\u003e\n      \u003cif condition='item.name'\u003e\n        \u003cp\u003e{{ item.name }}\u003c/p\u003e\n      \u003c/if\u003e\n      \u003celse\u003e\n        \u003cp\u003eitem with no name!\u003c/p\u003e\n      \u003c/else\u003e\n    \u003c/each\u003e\n\n    \u003cp mdi\u003e**Look** at this [markdown](https://daringfireball.net/projects/markdown/)\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nNote that it is easily possible to configure any of the options. If you don't like the names of any of the custom tags, you can change them in the options. If you don't like the `{{ }}` delimiters, you can quickly and easily change them, etc. See the options below for more!\n\nMany also enjoy using a more jade/pug/haml-like whitespace syntax. It's quite easy to add in [sugarml](https://github.com/reshape/sugarml) for this if you want by adding it as a dependency, requiring it, and passing `{ parser: sugarml }` into the options.\n\n### Usage\n\nThis is nothing more than a light wrapper around a reshape configuration object. Options are filtered into their appropriate plugins internally. All are optional.\n\n```js\nconst reshape = require('reshape')\nconst standard = require('reshape-standard')\n\nreshape(standard(/* options */))\n  .process(someHtml)\n  .then(res =\u003e console.log(res.output()))\n```\n\nBy default, the standard preset includes:\n\n* [reshape-expressions](https://github.com/reshape/expressions), default settings\n* [reshape-layouts](https://github.com/reshape/layouts), default settings\n* [reshape-include](https://github.com/reshape/include), default settings\n* [reshape-content](https://github.com/reshape/content) with `md` and `mdi` functions that render markdown using [markdown-it](https://github.com/markdown-it/markdown-it)\n* [reshape-retext](https://github.com/reshape/retext) with the [smartypants](https://github.com/wooorm/retext-smartypants) plugin\n* [reshape-beautify](https://github.com/reshape/beautify), default settings\n* [reshape-minify](https://github.com/reshape/minify), toggled with the `minify` option which is false by default. When enabled, it will disable `beautify`\n\nBased on the way they are ordered there are a couple limitations to keep in mind:\n\n* You cannot use a layout `block/extend` inside of an `include`\n* Any expression delimiters rendered from a `content` or `retext` transform will be output as plaintext, not as an expression\n* Output from a `content` transform will be processed by `retext` in that order\n\nAny of these plugins can be customized by passing options described below.\n\n### Options\n\n| Name                   | Description                                                                                                                                                                                                                          | Default                                                               |\n| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |\n| **root**               | Root path used to resolve layouts and includes                                                                                                                                                                                       |                                                                       |\n| **filename**           | Name of the file being compiled, used for error traces and as the include/layout root if not otherwise provided                                                                                                                      |                                                                       |\n| **delimiters**         | Delimiters used for html-escaped expressions                                                                                                                                                                                         | `['{{', '}}']`                                                        |\n| **unescapeDelimiters** | Delimiters used for unescaped expressions                                                                                                                                                                                            | `['{{{', '}}}']`                                                      |\n| **markdown**           | Options passed in to [markdown-it](https://github.com/markdown-it/markdown-it) constructor                                                                                                                                           | `{ typographer: true, linkify: true }`                                |\n| **markdownPlugins**    | Plugins to be loaded by [markdown-it](https://github.com/markdown-it/markdown-it) parser. See below for more details.                                                                                                                |                                                                       |\n| **content**            | Options passed to the [reshape-content](https://github.com/reshape/content) plugin                                                                                                                                                   | `{ md: renderMarkdown, mdi: renderMarkdownInline }`                   |\n| **parser**             | custom html parser if desired                                                                                                                                                                                                        |                                                                       |\n| **retext**             | Plugins to be passed to the [reshape-retext](https://github.com/reshape/retext) plugin                                                                                                                                               | `[smartypants]` ([ref](https://github.com/wooorm/retext-smartypants)) |\n| **locals**             | Added directly to the output object, used when compiling a reshape template to html                                                                                                                                                  | `{}`                                                                  |\n| **alias**              | Alias option to be passed to the [include plugin](https://github.com/reshape/include#options)                                                                                                                                        |                                                                       |\n| **parserRules**        | Parser rules to be passed to the [include plugin](https://github.com/reshape/include#options)                                                                                                                                        |                                                                       |\n| **minify**             | Minifies the html output by removing excess spaces and line breaks, comments, and by minifying inline CSS, JS, SVG and JSON. Accepts a boolean or an object of options passed to [reshape-minify](https://github.com/reshape/minify) | `false`                                                               |\n| **appendPlugins**      | Adds a single plugin or array of plugins after all the defaults                                                                                                                                                                      |                                                                       |\n| **prependPlugins**     | Adds a single plugin or array of plugins before all the defaults                                                                                                                                                                     |                                                                       |\n| **template**           | Set this to `true` if you are trying to output a client-side template function.                                                                                                                                                      | false                                                                 |\n| **locals**             | Optionally set your locals as soon as expressions are evaluated.                                                                                                                                                                     |                                                                       |\n| **multi**              | Pass through feature specific to [reshape-loader](https://github.com/reshape/loader#producing-multiple-outputs-from-a-single-files)                                                                                                  |                                                                       |\n\n### Markdown Rendering Functions\n\nThere are two markdown rendering shortcut functions provided with this preset: `md` and `mdi`. The `md` function will run a full markdown render including wrapping with a paragraph tag, rendering headlines, etc. For example:\n\n```\n\u003cdiv class='content' md\u003e\n  # The title\n\n  Here's some text, wow.\n\n  A second paragraph!\n\u003c/div\u003e\n```\n\nThis would work as expected, rendering title and paragraph tags:\n\n```\n\u003cdiv class='content'\u003e\n  \u003ch1\u003eThe title\u003c/h1\u003e\n  \u003cp\u003eHere's some text, wow.\u003c/p\u003e\n  \u003cp\u003eA second paragraph!\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThe `mdi` shortcut is specifically for rendering _inline_ markdown, not including any type of title tags or paragraph wrapping. So for example:\n\n```\n\u003cp mdi\u003eHello, I am #1 and this is [my link](#).\u003c/p\u003e\n```\n\nWould render without additional paragraph wrappings or unexpected title renders:\n\n```\n\u003cp\u003eHello, I am #1 and this is \u003ca href='#'\u003emy link\u003c/a\u003e.\n```\n\n### Markdown Plugins\n\nYou can pass an array of [markdown-it plugins](https://www.npmjs.com/browse/keyword/markdown-it-plugin) via the `markdownPlugins` option with or without their own options.\n\n```js\nconst reshape = require('reshape')\nconst standard = require('reshape-standard')\nconst emoji = require('markdown-it-emoji')\nconst anchor = require('markdown-it-anchor')\nconst toc = require('markdown-it-table-of-contents')\n\nreshape(\n  standard((markdownPlugins: [emoji, anchor, [toc, { containerClass: 'toc' }]]))\n)\n  .process(someHtml)\n  .then(res =\u003e console.log(res.output()))\n```\n\n### License \u0026 Contributing\n\n* Details on the license [can be found here](LICENSE.md)\n* Details on running tests and contributing [can be found here](contributing.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freshape%2Fstandard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freshape%2Fstandard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freshape%2Fstandard/lists"}