{"id":50959649,"url":"https://github.com/bananaacid/pugps","last_synced_at":"2026-06-18T12:02:10.907Z","repository":{"id":337730709,"uuid":"1154942860","full_name":"BananaAcid/PugPS","owner":"BananaAcid","description":"Unleash Pug templates in PowerShell. A versatile CLI for HTML pipelines and a loyal View Engine for your Pode Server projects. 🐾","archived":false,"fork":false,"pushed_at":"2026-02-11T01:38:35.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-11T05:16:45.524Z","etag":null,"topics":["cli","devops-tools","html-generator","jade-templates","pode","powershell","pug","pugjs","view-engine"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","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/BananaAcid.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-11T00:15:04.000Z","updated_at":"2026-02-11T01:38:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/BananaAcid/PugPS","commit_stats":null,"previous_names":["bananaacid/pugps"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/BananaAcid/PugPS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BananaAcid%2FPugPS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BananaAcid%2FPugPS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BananaAcid%2FPugPS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BananaAcid%2FPugPS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BananaAcid","download_url":"https://codeload.github.com/BananaAcid/PugPS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BananaAcid%2FPugPS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34489200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","devops-tools","html-generator","jade-templates","pode","powershell","pug","pugjs","view-engine"],"created_at":"2026-06-18T12:02:09.161Z","updated_at":"2026-06-18T12:02:10.900Z","avatar_url":"https://github.com/BananaAcid.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PugPS\n\n**Unleash Pug templates in PowerShell. A versatile CLI for HTML pipelines and a loyal View Engine for your Pode Server projects. 🐾**\n\nPugPS is a PowerShell-native implementation of the Pug (formerly Jade) templating engine. It allows you to write clean, indented templates and render them into HTML using PowerShell logic, variables, and functions (JavaScript logic is not supported).\n\n---\n\n## 📦 Installation\n\n```powershell\nInstall-Module -name PugPS\n```\n\n*Latest version:  https://github.com/BananaAcid/PugPS*\n\n---\n\n## ⭐ Examples and general documentation\n\nThe general [PugJS Language Reference](https://pugjs.org/language/attributes.html) applies. PowerShell specific usage is below.\n\nHow does Pug look like? See: https://html-to-pug.com/\n\n---\n\n## 🚀 Usage in Pode\n\nTo use PugPS as your view engine in a [Pode](https://badgerati.github.io/Pode/) server, import the module and initialize the engine within your `Start-PodeServer` block.\n\n```powershell\nStart-PodeServer {\n    # Import the view engine module\n    Import-Module PugPS\n    \n    # Configure the engine\n    Set-PodeViewEnginePug -Extension 'pode.pug' -ErrorOutput 'text'\n}\n```\n\n### `Set-PodeViewEnginePug` Parameters\n\n| Parameter | Type | Req | Default | Description |\n| :--- | :--- | :---: | :--- | :--- |\n| **-Extension** | `string` | Yes | - | The default file extension to target (e.g., `pode.pug`). |\n| **-BaseDir** | `string` | No | `\"\"` | The root directory used to resolve absolute include/extend paths (starting with `/` or `\\`). |\n| **-Filters** | `sb\\|string` | No | `$null` | The path to a `.ps1` filters file or a scriptblock containing filter functions. |\n| **-Properties** | `bool` | No | `$true` | When `$true` (default), boolean attributes render as `attr`. When `$false`, `attr='attr'`. |\n| **-VoidTagsSelfClosing** | `bool` | No | `$false` | When `$true`, standard void tags (like `img`, `br`) render as `\u003cimg /\u003e`. |\n| **-ContainerTagsSelfClosing** | `bool` | No | `$false` | When `$true`, empty container tags (like `div`) render as `\u003cdiv /\u003e`. |\n| **-KebabCaseHTML** | `bool` | No | `$true` | When `$true`, `CamelCase` tags in PUG are converted to `kebab-case`. |\n| **-ErrorOutput** | `string` | No | `'rethrow'` | `'text'` returns HTML error; `'rethrow'` triggers the Pode error page. |\n| **-ErrorContextRange** | `int` | No | `2` | Number of context lines to show before and after the error line. |\n| **-NoCache** | `switch` | No | `$false` | When `$true`, the internal cache is not used. |\n\n**Returns:** The converted and executed PUG as string.\n\n---\n\n## 💻 Usage as a CLI Tool\n\nUse `Invoke-PUG` for automation, build pipelines, or one-off conversions.\n\n```powershell\nImport-Module PugPS\n\n# Example 1: Convert a file with data and external filters\nInvoke-PUG -Path .\\test.pug -Data @{\n    Title = \"Pug PowerShell\"\n    Users = @(@{ Name = \"Alice\"; Role = \"Admin\" })\n} -Filters .\\helper.ps1\n\n# Example 2: Pipe content directly with a scriptblock filter\n@\"\ndiv\n    :MyFilter\n        Content\n\"@ | Invoke-PUG -Filters {\n    Function MyFilter { \n        param([Parameter(ValueFromPipeline=$true)]$text) \n        \"\u003cb\u003e$text\u003c/b\u003e\" \n    }\n}\n```\n\n### `Invoke-PUG` Parameters\n\n| Parameter | Type | Req | Default | Description |\n| :--- | :--- | :---: | :--- | :--- |\n| **-Path** | `string` | Yes* | - | Path to Pug Template file (Mandatory if not using pipeline). |\n| **-InputContent** | `string[]` | Yes* | - | The raw Pug template content (supports pipeline input). |\n| **-Data** | `hashtable` | No | `@{}` | The data passed to the template as `$data`. |\n| **-Filters** | `sb\\|string` | No | `$null` | Path to filters file (ps1) or a scriptblock with filter functions. |\n| **-Extension** | `string` | No | `'pug'` | The default file extension to use for included files. |\n| **-BaseDir** | `string` | No | `\"\"` | Root directory used to resolve absolute include/extend paths. |\n| **-Properties** | `bool` | No | `$true` | If `$true`, boolean attributes render as `attr`. |\n| **-VoidTagsSelfClosing** | `bool` | No | `$false` | If `$true`, void tags render with a self-closing slash. |\n| **-ContainerTagsSelfClosing** | `bool` | No | `$false` | If `$true`, empty container tags render as self-closing. |\n| **-KebabCaseHTML** | `bool` | No | `$true` | If `$true`, converts `CamelCase` tags to `kebab-case`. |\n| **-ErrorContextRange** | `int` | No | `2` | Context lines to show before/after error line. |\n\n**Returns:** The converted and executed PUG as string.\n\n#### Note\n`-InputContent` expects an array. Passing a single line into it, append a newline (`` `n ``).\n\nExample:\n```powershell\n\"div: b hi `n\" | Invoke-pug\n```\n\n---\n\n## 📝 Syntax Notes \u0026 Examples\n\n### 1. PowerShell Control Flow\nPugPS supports standard PowerShell logic using the `-` prefix.\n\n```pug\n- Foreach ($u in $data.Users)\n    li= $u.Name\n\n- If ($a -eq $true)\n    li TRUE\n- ElseIf ($a -eq $false)\n    li FALSE\n- Else\n    li Unknown\n\n- Switch ($data.Status)\n    - \"active\"\n        li User is Active\n    - \"disabled\"\n        li User is Locked\n    - default\n        li Status Unknown\n```\n\n#### NOTE: PugJS's Case, Conditionals, Iteration\n- these can be done with `- Foreach`, `- If`, `- For` ... while keeping the PowerShell syntax (the PugJS specific implementation is not supported)\n    - https://pugjs.org/language/case.html\n    - https://pugjs.org/language/conditionals.html\n    - https://pugjs.org/language/iteration.html\n\n\n\n### 2. Classes and Styles\nPugPS handles PowerShell collections intelligently for clean attribute management.\n\n*   **Classes from Array:** Simple list output.\n    ```pug\n    - $classes = \"btn\", \"btn-primary\"\n    button(class=$classes) // \u003cbutton class=\"btn btn-primary\"\u003e\n    ```\n*   **Classes from Object:** Keys mapped to `$true` are included; `$false` are omitted.\n    ```pug\n    - $classesObj = @{ active = $true; hidden = $false }\n    div(class=$classesObj) // \u003cdiv class=\"active\"\u003e\n    ```\n*   **Styles from Object:** Keys in `camelCase` are automatically converted to `kebab-case`.\n    ```pug\n    - $styles = @{ backgroundColor = \"red\"; borderRadius = \"5px\" }\n    div(style=$styles) // \u003cdiv style=\"background-color:red;border-radius:5px\"\u003e\n    ```\n\n### 3. Variables \u0026 Interpolation\n*   **Attribute Values:** These are PowerShell expressions. Double quotes `\" \"` expand variables; single quotes `' '` do not.\n*   **Content Interpolation:** Use `$( $var )` or `${ $var }` for raw content, and `#( $var )` or `#{ $var }` for escpaed HTML content. Preferred: use `$()` and `#()`.\n*   **Escaping:** To escape a dollar sign in content, use `\\$` or `` `$ ``. (`\\` and `` ` `` can be escaped as well.)\n\n#### Examples\n- `ps1 attr='$a'`  var will not be parsed (singe quotes),\n- `attr=\"$a\"`  var will be parsed (double quotes),\n- `$attr=$a`   var will be parsed (no quotes).\n\n#### Note: Attributes with Code\nFor `body(class=$authenticated ? 'authed' : 'anon' ...)` and alike, you should use `body(class=$($authenticated ? 'authed' : 'anon') ...)` - wrapping the logic in `$()`\n\n### 4. Filters\nFilters trigger standard PowerShell functions. The nested content is passed via the pipeline. Params are used by their names, the multiline content is piped in as single string.\n\n```pug\n:MyFilter(paramname=\"value\")\n    Content here is passed to the function\n```\n\n#### Filter\nTo access the pipeline value use the param `[Parameter(ValueFromPipeline=$true)]$text` (Content is passed as one single string, there is no need to collect lines or use $input)\n\n\n```ps1\nFunction TestFN {\n    param(\n        $title,\n        [Parameter(ValueFromPipeline=$true)]$text\n    )\n\n    \"\u003cdiv\u003e\" $title + '\u003cbr\u003e' +  ($text ? $text : \"-- no text --\") + \"\u003cdiv\u003e\"\n}\n```\n\nA filter can also be created inline in within the Pug (like using `- Function TestFN{...}`) or made available by the `-Filters` param.\n\n\n### 5. Doctypes \u0026 XML\n*   **Shortcuts:** `5` (== html), `svg1.1`, `smil1`, `smil2`. And for the PugJS default ones [look them up here](https://pugjs.org/language/doctype.html)\n*   **Casing:** When using the XML doctype, `KebabCaseHTML` is automatically disabled to preserve XML casing.\n*   **XML Mode:** For XML types (plist, svg1.1, smil1, smil2, etc.), always include `doctype xml` first.\n\nExample:\n```pug\ndoctype xml\ndoctype plist\nplist(version=\"1.0\")\n  dict\n    ...\n```\n**Note:** A specific doctype for SVG Tiny 1.1 and 1.2 is not recomended. Only use: `doctype xml`\n\n\n### 6. Includes \u0026 Mixins \u0026 Template Inheritance (Extends)\nAre supported as defined by PugJS.\n\n- https://pugjs.org/language/includes.html\n- https://pugjs.org/language/mixins.html\n- https://pugjs.org/language/inheritance.html\n\n\n---\n\n## ⚙️ Manual Transpilation\n\nIf you need to generate the PowerShell script representation of a Pug file without immediately rendering it, use `Convert-PugToPowerShell`.\n\nYou need to save the module into your project first:\n```powershell\nSave-Module -Name PugPS -Path .\\   # this creates a subfolder .\\PugPS\\1.1.0\\\n```\n\nThen use it:\n\n```powershell\n. .\\PugPS\\1.0.0\\parser.ps1\n$psCode = Convert-PugToPowerShell -Path \"template.pug\" -KebabCaseHTML $true\n```\n\n### `Convert-PugToPowerShell` Parameters\n\n| Parameter | Type | Req | Default | Description |\n| :--- | :--- | :---: | :--- | :--- |\n| **-Path** | `string` | Yes* | - | Path to Pug Template file (Mandatory if not using pipeline). |\n| **-InputContent** | `string[]` | Yes* | - | The raw Pug template content (supports pipeline input). |\n| **-Extension** | `string` | No | `'pug'` | Extension for included files. |\n| **-BaseDir** | `string` | No | `\"\"` | Root directory for absolute paths. |\n| **-Properties** | `bool` | No | `$true` | Render boolean attributes as `attr`. |\n| **-VoidTagsSelfClosing** | `bool` | No | `$false` | Render void tags with `/`. |\n| **-ContainerTagsSelfClosing** | `bool` | No | `$false` | Render empty containers with `/`. |\n| **-KebabCaseHTML** | `bool` | No | `$true` | Convert `CamelCase` tags to `kebab-case`. |\n| **-ErrorContextRange** | `int` | No | `2` | Error context line count. |\n\n**Returns:** PowerShell script block as string with param `-Data` for an input object. To get the html, use it like :\n```powershell\n$sb = [scriptblock]::Create($psCode)\n\n$Data = @{\n    something = \"to make available\"  # provies $Data.something to be used in PUG\n}\n\n$html = (\u0026 $sb -Data $Data)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbananaacid%2Fpugps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbananaacid%2Fpugps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbananaacid%2Fpugps/lists"}