{"id":14967538,"url":"https://github.com/joker/jade","last_synced_at":"2025-05-16T11:03:53.435Z","repository":{"id":27275724,"uuid":"30748934","full_name":"Joker/jade","owner":"Joker","description":"Jade.go - pug template engine for Go (golang) ","archived":false,"fork":false,"pushed_at":"2023-12-25T00:24:44.000Z","size":238,"stargazers_count":359,"open_issues_count":11,"forks_count":36,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-16T11:03:51.977Z","etag":null,"topics":["go","golang","golang-library","html","jade","pug","pug-template-engine","template","template-engine","templates"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"openalea/sconsx","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Joker.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-02-13T09:13:36.000Z","updated_at":"2025-05-16T00:00:15.000Z","dependencies_parsed_at":"2024-06-18T12:31:25.862Z","dependency_job_id":"690768f9-68c7-4f45-ad09-e803cc72b860","html_url":"https://github.com/Joker/jade","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joker%2Fjade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joker%2Fjade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joker%2Fjade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joker%2Fjade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Joker","download_url":"https://codeload.github.com/Joker/jade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"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":["go","golang","golang-library","html","jade","pug","pug-template-engine","template","template-engine","templates"],"created_at":"2024-09-24T13:38:13.368Z","updated_at":"2025-05-16T11:03:53.419Z","avatar_url":"https://github.com/Joker.png","language":"Go","readme":"# Jade.go - template engine for Go (golang)  \nPackage jade (github.com/Joker/jade) is a simple and fast template engine implementing Jade/Pug template.  \nJade precompiles templates to Go code or generates html/template.  \nNow Jade-lang is renamed to [Pug template engine](https://pugjs.org/language/tags.html).  \n\n[![GoDoc](https://godoc.org/github.com/Joker/jade?status.svg)](https://pkg.go.dev/github.com/Joker/jade#section-documentation) [![Go Report Card](https://goreportcard.com/badge/github.com/Joker/jade)](https://goreportcard.com/report/github.com/Joker/jade)\n\n## Jade/Pug syntax\nexample:\n\n```jade\n//-  :go:func Index(pageTitle string, youAreUsingJade bool)\n\nmixin for(golang)\n    #cmd Precompile jade templates to #{golang} code.\n\ndoctype html\nhtml(lang=\"en\")\n    head\n        title= pageTitle\n        script(type='text/javascript').\n            if(question){\n                answer(40 + 2)\n            }\n    body\n        h1 Jade - template engine\n            +for('Go')\n\n        #container.col\n            if youAreUsingJade\n                p You are amazing\n            else\n                p Get on it!\n            p.\n                Jade/Pug is a terse and simple\n                templating language with\n                a #[strong focus] on performance \n                and powerful features.\n```\n\nbecomes\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eJade.go\u003c/title\u003e\n        \u003cscript type=\"text/javascript\"\u003e\n            if(question){\n                answer(40 + 2)\n            }\n        \u003c/script\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eJade - template engine\n            \u003cdiv id=\"cmd\"\u003ePrecompile jade templates to Go code.\u003c/div\u003e\n        \u003c/h1\u003e\n        \u003cdiv id=\"container\" class=\"col\"\u003e\n            \u003cp\u003eYou are amazing\u003c/p\u003e\n            \u003cp\u003e\n                Jade/Pug is a terse and simple\n                templating language with\n                a \u003cstrong\u003efocus\u003c/strong\u003e on performance \n                and powerful features.\n            \u003c/p\u003e\n        \u003c/div\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nHere are additional [examples](https://github.com/Joker/jade/tree/master/example) and [test cases](https://github.com/Joker/jade/tree/master/testdata/v2).\n\n## Installation\nInstall [jade compiler](https://github.com/Joker/jade/tree/master/cmd/jade)\n```console\ngo install github.com/Joker/jade/cmd/jade@latest\n```\nor github.com/Joker/jade package\n```console\ngo get -u github.com/Joker/jade\n```\n\n## Example usage\n\n### jade compiler\n```console\njade -writer -pkg=main hello.jade\n```\n\njade command[^1] precompiles _hello.jade_ to _hello.jade.go_  \n\n`hello.jade`\n```\n:go:func(arg) word string\ndoctype 5\nhtml\n    body\n        p Hello #{word}!\n```\n\n`hello.jade.go`\n```go\n// Code generated by \"jade.go\"; DO NOT EDIT.\npackage main\n\nimport \"io\"\n\nconst (\n    hello__0 = `\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003cp\u003eHello `\n    hello__1 = `!\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e`\n)\nfunc Jade_hello(word string, wr io.Writer) {\n    buffer := \u0026WriterAsBuffer{wr}\n    buffer.WriteString(hello__0)\n    WriteEscString(word, buffer)\n    buffer.WriteString(hello__1)\n}\n```\n\n`main.go`\n```go\npackage main\n//go:generate jade -pkg=main -writer hello.jade\n\nimport \"net/http\"\n\nfunc main() {\n    http.HandleFunc(\"/\", func(wr http.ResponseWriter, req *http.Request) {\n        Jade_hello(\"jade\", wr)\n    })\n    http.ListenAndServe(\":8080\", nil)\n}\n```\n\noutput at localhost:8080\n```html\n\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003cp\u003eHello jade!\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\n```\n\n### github.com/Joker/jade package\ngenerate [`html/template`](https://pkg.go.dev/html/template#hdr-Introduction) at runtime\n(This case is slightly slower and doesn't support[^2] all features of Jade.go)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"html/template\"\n    \"net/http\"\n\n    \"github.com/Joker/hpp\" // Prettify HTML\n    \"github.com/Joker/jade\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n    jadeTpl, _ := jade.Parse(\"jade\", []byte(\"doctype 5\\n html: body: p Hello #{.Word} !\"))\n    goTpl, _ := template.New(\"html\").Parse(jadeTpl)\n\n    fmt.Printf(\"output:%s\\n\\n\", hpp.PrPrint(jadeTpl))\n    goTpl.Execute(w, struct{ Word string }{\"jade\"})\n}\n\nfunc main() {\n    http.HandleFunc(\"/\", handler)\n    http.ListenAndServe(\":8080\", nil)\n}\n```\n\nconsole output\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003cp\u003eHello {{.Word}} !\u003c/p\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\noutput at localhost:8080\n```html\n\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003cp\u003eHello jade !\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\n```\n\n## Performance\nThe data of chart comes from [SlinSo/goTemplateBenchmark](https://github.com/SlinSo/goTemplateBenchmark).\n![chart](https://user-images.githubusercontent.com/11617/141963788-3bf16698-c41e-4dc7-9f11-80d9473009ad.png)\n\n## Custom filter  :go\nThis filter is used as helper for command line tool  \n(to set imports, function name and parameters).  \nFilter may be placed at any nesting level.  \nWhen Jade used as library :go filter is not needed.  \n\n### Nested filter  :func\n```\n:go:func\n    CustomNameForTemplateFunc(any []int, input string, args map[string]int)\n\n:go:func(name)\n    OnlyCustomNameForTemplateFunc\n\n:go:func(args)\n    (only string, input float32, args uint)\n```\n\n### Nested filter  :import\n```\n:go:import\n    \"github.com/Joker/jade\"\n    github.com/Joker/hpp\n```\n\n#### note\n[^1]:\n    `Usage: ./jade [OPTION]... [FILE]...`  \n    ```\n    -basedir string\n            base directory for templates (default \"./\")\n    -d string\n            directory for generated .go files (default \"./\")\n    -fmt\n            HTML pretty print output for generated functions\n    -inline\n            inline HTML in generated functions\n    -pkg string\n            package name for generated files (default \"jade\")\n    -stdbuf\n            use bytes.Buffer  [default bytebufferpool.ByteBuffer]\n    -stdlib\n            use stdlib functions\n    -writer\n            use io.Writer for output\n    ```\n[^2]:\n    Runtime `html/template` generation doesn't support the following features:  \n    `=\u003e` means it generate the folowing template  \n    ```\n\tfor                =\u003e  \"{{/* %s, %s */}}{{ range %s }}\"\n\tfor if             =\u003e  \"{{ if gt len %s 0 }}{{/* %s, %s */}}{{ range %s }}\"\n\n\tmultiline code     =\u003e  \"{{/* %s */}}\"\n\tinheritance block  =\u003e  \"{{/* block */}}\"\n\n\tcase statement     =\u003e  \"{{/* switch %s */}}\"\n\twhen               =\u003e  \"{{/* case %s: */}}\"\n\tdefault            =\u003e  \"{{/* default: */}}\"\n    ```\n    You can change this behaviour in [`config.go`](https://github.com/Joker/jade/blob/master/config.go#L24) file.  \n    Partly this problem can be solved by [custom](https://pkg.go.dev/text/template#example-Template-Func) functions.  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoker%2Fjade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoker%2Fjade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoker%2Fjade/lists"}