{"category":{"version":"58c81e8e693cdd1900606acf","project":"542fe92a5eceb608003fddc8","_id":"58c81e8e693cdd1900606ad3","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-04T12:45:40.548Z","from_sync":false,"order":3,"slug":"helper-reference","title":"Helper Reference"},"parentDoc":null,"project":"542fe92a5eceb608003fddc8","user":"542c5cfcddd3190e00228849","version":{"__v":1,"_id":"58c81e8e693cdd1900606acf","project":"542fe92a5eceb608003fddc8","createdAt":"2017-03-14T16:47:10.620Z","releaseDate":"2017-03-14T16:47:10.620Z","categories":["58c81e8e693cdd1900606ad0","58c81e8e693cdd1900606ad1","58c81e8e693cdd1900606ad2","58c81e8e693cdd1900606ad3","58c81e8e693cdd1900606ad4","58c81e8e693cdd1900606ad5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.11.7","version":"0.11.7"},"_id":"58c81e8e693cdd1900606ae4","__v":0,"updates":["5436f6ab775c241600f98025","5471590b208b72080024afa3"],"next":{"pages":[],"description":""},"createdAt":"2014-10-04T19:28:45.161Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":25,"body":"[block:html]\n{\n  \"html\": \"<div class=\\\"github-deeplinks\\\">\\n    <a href=\\\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/body_class.js\\\"><i class=\\\"fa fa-github-alt fa-right\\\"></i>Source</a>\\n    <a href=\\\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/test/unit/server_helpers/body_class_spec.js\\\"><i class=\\\"fa fa-check-square-o fa-right\\\"></i>Tests</a>\\n</div>\"\n}\n[/block]\nUsage: `{{body_class}}`\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Type\",\n    \"h-1\": \"Parameters\",\n    \"h-2\": \"Attributes\",\n    \"0-0\": \"[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)\",\n    \"0-1\": \"n/a\",\n    \"0-2\": \"n/a\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Deprecations\",\n  \"body\": \"There are several deprecated classes that are output by {{body_class}}. These will be removed in Ghost 1.0. If the class isn't listed in the context table, then it is deprecated and should not be used.\"\n}\n[/block]\n### Description\n\n`{{body_class}}` – outputs dynamic CSS classes intended for the `<body>` tag in your `default.hbs` or other layout file, and is useful for targeting specific pages (or contexts) with styles.\n\nThe `{{body_class}}` helper outputs different classes on different pages, depending on what context the page belongs to. For example the home page will get the class `.home-template`, but a single post page would get `.post-template`. \n\nFull details of what is output on each page can be found in the [context table](/docs/context-overview#section-context-table) on the [Context Overview](doc:context-overview) page.\n\n### Examples\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Hint\",\n  \"body\": \"Switch between the Handlebars and HTML tabs to see the the output from the helper\"\n}\n[/block]\nHandlebars from `default.hbs`, HTML as would be output on `/page/2` of a blog:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<html>\\n    <head>...</head>\\n    <body class=\\\"{{body_class}}\\\">\\n    ...\\n    {{{body}}}\\n    ...\\n    </body>\\n</html>\",\n      \"language\": \"html\",\n      \"name\": \"Handlebars\"\n    },\n    {\n      \"code\": \"<html>\\n    <head>...</head>\\n    <body class=\\\"home-template paged\\\">\\n    ...\\n    </body>\\n</html>\",\n      \"language\": \"text\",\n      \"name\": \"HTML\"\n    }\n  ]\n}\n[/block]\nHandlebars from `default.hbs`, HTML as would be output on a static page with the permalink `/about/`\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<html>\\n    <head>...</head>\\n    <body class=\\\"{{body_class}}\\\">\\n    ...\\n    {{{body}}}\\n    ...\\n    </body>\\n</html>\",\n      \"language\": \"html\",\n      \"name\": \"Handlebars\"\n    },\n    {\n      \"code\": \"<html>\\n    <head>...</head>\\n    <body class=\\\"page-template\\\">\\n    ...\\n    </body>\\n</html>\",\n      \"language\": \"html\",\n      \"name\": null\n    }\n  ]\n}\n[/block]","excerpt":"`{{body_class}}` Helper - Outputs dynamic CSS classes to identify the context of the page","slug":"body_class","type":"basic","title":"body_class"}

body_class

`{{body_class}}` Helper - Outputs dynamic CSS classes to identify the context of the page

[block:html] { "html": "<div class=\"github-deeplinks\">\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/body_class.js\"><i class=\"fa fa-github-alt fa-right\"></i>Source</a>\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/test/unit/server_helpers/body_class_spec.js\"><i class=\"fa fa-check-square-o fa-right\"></i>Tests</a>\n</div>" } [/block] Usage: `{{body_class}}` [block:parameters] { "data": { "h-0": "Type", "h-1": "Parameters", "h-2": "Attributes", "0-0": "[Output](/docs/helpers#section-output), [Ghost](/docs/helpers#section-ghost)", "0-1": "n/a", "0-2": "n/a" }, "cols": 3, "rows": 1 } [/block] [block:callout] { "type": "warning", "title": "Deprecations", "body": "There are several deprecated classes that are output by {{body_class}}. These will be removed in Ghost 1.0. If the class isn't listed in the context table, then it is deprecated and should not be used." } [/block] ### Description `{{body_class}}` – outputs dynamic CSS classes intended for the `<body>` tag in your `default.hbs` or other layout file, and is useful for targeting specific pages (or contexts) with styles. The `{{body_class}}` helper outputs different classes on different pages, depending on what context the page belongs to. For example the home page will get the class `.home-template`, but a single post page would get `.post-template`. Full details of what is output on each page can be found in the [context table](/docs/context-overview#section-context-table) on the [Context Overview](doc:context-overview) page. ### Examples [block:callout] { "type": "info", "title": "Hint", "body": "Switch between the Handlebars and HTML tabs to see the the output from the helper" } [/block] Handlebars from `default.hbs`, HTML as would be output on `/page/2` of a blog: [block:code] { "codes": [ { "code": "<html>\n <head>...</head>\n <body class=\"{{body_class}}\">\n ...\n {{{body}}}\n ...\n </body>\n</html>", "language": "html", "name": "Handlebars" }, { "code": "<html>\n <head>...</head>\n <body class=\"home-template paged\">\n ...\n </body>\n</html>", "language": "text", "name": "HTML" } ] } [/block] Handlebars from `default.hbs`, HTML as would be output on a static page with the permalink `/about/` [block:code] { "codes": [ { "code": "<html>\n <head>...</head>\n <body class=\"{{body_class}}\">\n ...\n {{{body}}}\n ...\n </body>\n</html>", "language": "html", "name": "Handlebars" }, { "code": "<html>\n <head>...</head>\n <body class=\"page-template\">\n ...\n </body>\n</html>", "language": "html", "name": null } ] } [/block]