{"id":16934974,"url":"https://github.com/codeskyblue/macaron-jade","last_synced_at":"2026-05-09T15:41:51.264Z","repository":{"id":152245083,"uuid":"43348129","full_name":"codeskyblue/macaron-jade","owner":"codeskyblue","description":"Jade template engine for macaron","archived":false,"fork":false,"pushed_at":"2015-09-29T10:33:13.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T01:17:11.056Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeskyblue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-29T06:01:35.000Z","updated_at":"2016-03-07T23:32:18.000Z","dependencies_parsed_at":"2023-04-09T18:43:11.484Z","dependency_job_id":null,"html_url":"https://github.com/codeskyblue/macaron-jade","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fmacaron-jade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fmacaron-jade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fmacaron-jade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fmacaron-jade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeskyblue","download_url":"https://codeload.github.com/codeskyblue/macaron-jade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244735912,"owners_count":20501365,"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-10-13T20:53:24.037Z","updated_at":"2026-05-09T15:41:46.239Z","avatar_url":"https://github.com/codeskyblue.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Macaron-jade\n[![GoDoc](https://godoc.org/github.com/codeskyblue/macaron-jade?status.svg)](https://godoc.org/github.com/codeskyblue/macaron-jade)\n\nMacaron middleware/handler for easily rendering serialized JSON and HTML template responses from Jade templates.\n\nIf you donot know about jade, [learn from here](http://www.learnjade.com/)\n\n## Usage\nThis middleware uses Jade implementation in Go [go-floki/jade](https://github.com/go-floki/jade) to render Jade templates.\n\nSome examples can be found in [examples](examples)\n\n~~~ go\n// main.go\npackage main\n\nimport (\n\t\"github.com/Unknwon/macaron\"\n\t\"github.com/codeskyblue/macaron-jade\"\n)\n\nfunc main() {\n\tm := macaron.Classic()\n\t// render html templates from templates directory\n\tm.Use(jade.Renderer())\n\n\tm.Get(\"/\", func(r jade.Render) {\n\t\tr.HTML(200, \"hello\", map[string]string{\n\t\t\t\"foo\": \"bar\",\n\t\t})\n\t})\n\n\tm.Run()\n}\n~~~\n\nFile `templates/hello.jade`\n\n~~~ html\nh2 Hello #{foo}!\n~~~\n\n### Options\n`jade.Renderer` comes with a variety of configuration options:\n\n**Layout** is not supported.\n\n~~~ go\n// ...\nm.Use(jade.Renderer(jade.Options{\n  Directory: \"templates\", // Specify what path to load the templates from.\n  Extensions: []string{\".jade\"}, // Specify extensions to load for templates.\n  Funcs: []template.FuncMap{AppHelpers}, // Specify helper function maps for templates to access.\n  Charset: \"UTF-8\", // Sets encoding for json and html content-types. Default is \"UTF-8\".\n  IndentJSON: true, // Output human readable JSON\n}))\n// ...\n~~~\n\n### Loading Templates\nBy default the `jade.Renderer` middleware will attempt to load templates with a '.jade' extension from the \"templates\" directory. Templates are found by traversing the templates directory and are named by path and basename. For instance, the following directory structure:\n\n~~~\ntemplates/\n  |\n  |__ admin/\n  |      |\n  |      |__ index.jade\n  |      |\n  |      |__ edit.jade\n  |\n  |__ home.jade\n~~~\n\nWill provide the following templates:\n~~~\nadmin/index\nadmin/edit\nhome\n~~~\n\n### Character Encodings\nThe `jade.Renderer` middleware will automatically set the proper Content-Type header based on which function you call. See below for an example of what the default settings would output (note that UTF-8 is the default):\n~~~ go\n// main.go\npackage main\n\nimport (\n  \"github.com/Unknwon/macaron\"\n  \"github.com/codeskyblue/macaron-jade\"\n)\n\nfunc main() {\n  m := macaron.Classic()\n  m.Use(jade.Renderer())\n\n  // This will set the Content-Type header to \"text/html; charset=UTF-8\"\n  m.Get(\"/\", func(r jade.Render) {\n    r.HTML(200, \"hello\", \"world\")\n  })\n\n  // This will set the Content-Type header to \"application/json; charset=UTF-8\"\n  m.Get(\"/api\", func(r jade.Render) {\n    r.JSON(200, map[string]interface{}{\"hello\": \"world\"})\n  })\n\n  m.Run()\n}\n\n~~~\n\nIn order to change the charset, you can set the `Charset` within the `jade.Options` to your encoding value:\n~~~ go\n// main.go\npackage main\n\nimport (\n  \"github.com/Unknwon/macaron\"\n  \"github.com/codeskyblue/macaron-jade\"\n)\n\nfunc main() {\n  m := macaron.Classic()\n  m.Use(jade.Renderer(render.Options{\n    Charset: \"ISO-8859-1\",\n  }))\n\n  // This is set the Content-Type to \"text/html; charset=ISO-8859-1\"\n  m.Get(\"/\", func(r jade.Render) {\n    r.HTML(200, \"hello\", \"world\")\n  })\n\n  // This is set the Content-Type to \"application/json; charset=ISO-8859-1\"\n  m.Get(\"/api\", func(r jade.Render) {\n    r.JSON(200, map[string]interface{}{\"hello\": \"world\"})\n  })\n\n  m.Run()\n}\n\n~~~\n\n## Authors\n* [Jeremy Saenz](http://github.com/codegangsta)\n* [Cory Jacobsen](http://github.com/cojac)\n* [frogprog](http://github.com/frogprog)\n* [codeskyblue](http://github.com/codeskyblue)\n* [Unknwon](http://github.com/Unknwon)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fmacaron-jade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeskyblue%2Fmacaron-jade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fmacaron-jade/lists"}