{"id":13554711,"url":"https://github.com/aMarCruz/pugjs-brunch","last_synced_at":"2025-04-03T07:32:24.438Z","repository":{"id":66183612,"uuid":"72267384","full_name":"aMarCruz/pugjs-brunch","owner":"aMarCruz","description":"Adds Pug (aka Jade) support to brunch.","archived":false,"fork":false,"pushed_at":"2018-12-31T23:51:46.000Z","size":61,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T15:19:24.773Z","etag":null,"topics":["brunch","jade","javascript","plugin","plugins","pug","template"],"latest_commit_sha":null,"homepage":null,"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/aMarCruz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-29T05:44:32.000Z","updated_at":"2022-12-13T11:27:49.000Z","dependencies_parsed_at":"2023-02-23T01:15:56.212Z","dependency_job_id":null,"html_url":"https://github.com/aMarCruz/pugjs-brunch","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Fpugjs-brunch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Fpugjs-brunch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Fpugjs-brunch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Fpugjs-brunch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aMarCruz","download_url":"https://codeload.github.com/aMarCruz/pugjs-brunch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246956669,"owners_count":20860475,"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":["brunch","jade","javascript","plugin","plugins","pug","template"],"created_at":"2024-08-01T12:02:53.355Z","updated_at":"2025-04-03T07:32:24.159Z","avatar_url":"https://github.com/aMarCruz.png","language":"JavaScript","funding_links":["https://ko-fi.com/C0C7LF7I"],"categories":["JavaScript","javascript"],"sub_categories":[],"readme":"# pugjs-brunch\n\n[![npm Version][npm-image]][npm-url]\n[![Windows build][wbuild-image]][wbuild-url]\n[![Build Status][build-image]][build-url]\n[![License][license-image]][license-url]\n\nAdds [Pug](https://pugjs.org) v2.x (aka Jade) support to [Brunch](http://brunch.io)\n\nThis plugin compiles templates into any of three types:\n\n- Dynamic: Parameterized function that creates HTML at runtime based on the received parameters.\n- Precompiled: Returns raw HTML string with minimum overhead at runtime.\n- Static: Plain HTML files from pug templates in the `assets` directory.\n\nSee the changes for this version in the [CHANGELOG](CHANGELOG.md).\n\n## Install\n\n```bash\nnpm install pugjs-brunch --save-dev\n# or\nyarn add pugjs-brunch -D\n```\n\nor through `devDependencies` in `package.json`:\n\n```js\n  \"pugjs-brunch\": \"^2.11.2\",\n```\n\nTo compile pug into static, plain HTML, just place your files into the assets directory (usually `app/assets`).\n\n## The runtime\n\nFor modules, unless the `inlineRuntimeFunctions` option is set to `true` (not recommended), it is neccesary the Pug runtime, a small set of functions that lives in the *global* variable `pug`.\n\nIf required, the plugin loads a runtime from its own directory, so you don't have to worry about this.\n\n**NOTE:**\n\nUnder certain circumstances the loading of the runtime may fail. If this happens to you, move `pug_runtime.js` from `node_modules/pugjs-brunch/vendor` to your `vendor` folder and load it in the global scope. Example:\n\n```js\n  // In your brunch config\n  plugins: {\n    pug: { pugRuntime: false }\n  }\n```\n\n```html\n  \u003c!-- in your index.html file --\u003e\n  \u003cscript\u003e\n    require('pug_runtime')\n    $(document).ready(function() {\n      require('app')\n    })\n  \u003c/script\u003e\n```\n\n## Options\n\nThe plugin uses the `plugins.pug` section of your brunch-config and defines this properties:\n\nName            | Type    | Default    | Notes\n--------------- | ------- | ---------- | -----------\n`locals`        | any     |            |  Plain JavaScript object passed to Pug for static compilation.\n`staticBasedir` | string  | (brunch)   | Brunch `convention.assets` folder as **string**. This is the root of static templates.\n`staticPretty`  | boolean | true       | Pug's `pretty` option for files in `staticBasedir`, see NOTE (v2.8.5).\n`preCompilePattern` | RegExp | /\\.html\\.pug$/ | pre-compile the templates matching this regex (v2.8.6).\n`pugRuntime`    | boolean | true       | Set to `false` if you want to load another runtime.\n`sourceMap`     | boolean | true       | Defaults to brunch `sourceMaps` (with 's') value, `false` disables it (v2.8.4).\n\n### Note\n\nFrom v2.11.1 `staticPretty` is set to `false` for production builds. Thanks to @stawberri\n\nYou can use any [Pug options](https://pugjs.org/api/reference.html) as well, pugjs-brunch set this:\n\n```js\n{\n  doctype: 'html',\n  basedir: 'app',      // or wherever Brunch config says\n  compileDebug: true,  // false if brunch `optimize` mode is 'production'\n}\n```\n\n**TIP:**\n\nUse `preCompilePattern: /\\S/` to evaluate all the templates at build time.\n\n### About `staticBasedir`\n\nThis option is only meaningful if you changed the default value of `conventions.assets` in the Brunch config and you are using absolute paths in includes or extends. This value will be pass to Pug as `basedir` when compiling static assets as html (see the [pug options](https://pugjs.org/api/reference.html#options)).\n\n**NOTE:**\n\nThe options `pretty` and `compileDebug` are forced to `false` in production mode.\n\n## Examples\n\n### Dynamic templates\n\n```js\n  // brunch-config.js\n  ...\n  plugins: {\n    pug: {}\n  },\n```\n\n```jade\n  //- app/views/tmpl.pug\n  p= name\n```\n\n```js\n  // in the js code\n  ...\n  const tmplFn = require('views/tmpl.pug')\n  $('#elem').html(tmplFn({ name: 'John Doe' }))\n  // now #elem contains \u003cp\u003eJohn Doe\u003c/p\u003e\n```\n\n### Precompilation\n\n```js\n  // brunch-config.js\n  ...\n  plugins: {\n    pug: {\n      locals: { name: 'John Doe' },\n      preCompilePattern: /\\.html\\.pug$/\n    }\n  },\n```\n\n```jade\n  //- app/views/tmpl.html.pug\n  p= name\n```\n\n```js\n  // in the js code\n  ...\n  const htmlStr = require('views/tmpl.html.pug')\n  $('#elem').html(htmlStr)\n  // now #elem contains \u003cp\u003eJohn Doe\u003c/p\u003e\n```\n\n### Static files\n\n```js\n  // brunch-config.js\n  ...\n  plugins: {\n    pug: {\n      locals: { name: 'John Doe' }\n    }\n  },\n```\n\n```jade\n  //- app/assets/user.pug\n  doctype html\n  html\n    head\n      meta(charset=\"utf-8\")\n    body\n      p= name\n```\n\nwill create the file ./public/user.html\n\n### Using with [jscc-brunch](https://www.npmjs.com/package/jscc-brunch)\n\n```js\n  ...\n  plugins: {\n    jscc: {\n      values: {\n        _APP: 'My App'  // $_APP can do static replacement\n      },\n      pattern: /\\.(?:js|pug)$/,\n      sourceMapFor: /\\.(?:js|pug)$/,\n      sourceMap: true\n    },\n    pug: {\n      globals: ['$_APP']\n    }\n  }\n  ...\n```\n\n## Support my Work\n\nI'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time and effort so, if you like my work, please consider...\n\n\u003c!-- markdownlint-disable MD033 --\u003e\n[\u003cimg src=\"https://amarcruz.github.io/images/kofi_blue.png\" height=\"36\" title=\"Support Me on Ko-fi\" /\u003e][kofi-url]\n\u003c!-- markdownlint-enable MD033 --\u003e\n\nOf course, feedback, PRs, and stars are also welcome 🙃\n\nThanks for your support!\n\n## License\n\nThe [MIT License](LICENCE) (MIT)\n\n\u0026copy; 2016-2018 Alberto Martínez\n\n[npm-image]:      https://img.shields.io/npm/v/pugjs-brunch.svg\n[npm-url]:        https://www.npmjs.com/package/pugjs-brunch\n[license-image]:  https://img.shields.io/npm/l/express.svg\n[license-url]:    https://github.com/aMarCruz/pugjs-brunch/blob/master/LICENSE\n[build-image]:    https://img.shields.io/travis/aMarCruz/pugjs-brunch.svg\n[build-url]:      https://travis-ci.org/aMarCruz/pugjs-brunch\n[wbuild-image]:   https://ci.appveyor.com/api/projects/status/3www03fp83018461?svg=true\n[wbuild-url]:     https://ci.appveyor.com/project/aMarCruz/pugjs-brunch\n[kofi-url]:       https://ko-fi.com/C0C7LF7I\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Fpugjs-brunch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FaMarCruz%2Fpugjs-brunch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Fpugjs-brunch/lists"}