{"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":"58c81e8e693cdd1900606afc","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-04T19:40:28.068Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":49,"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/tags.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/tags_spec.js\\\" class=\\\"fa fa-check-square-o fa-right\\\">Tests</a>\\n</div>\"\n}\n[/block]\nUsage: `{{tags}}` or `{{#foreach tags}}{{/foreach}}` in `tag.hbs` you can use `{{#tag}}{{/tag}}` to access tag properties\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\": \"* `separator` (string, default \\\", \\\")\\n* `suffix` (string)\\n* `prefix` (string)\\n* `autolink` (boolean)\\n* `limit` (number)\\n* `from` (number)\\n* `to` (number)\\n* `visibility` (string, default \\\"public\\\")\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n### Description\n\n`{{tags}}` is a formatting helper for outputting a linked list of tags for a particular post. It defaults to a comma-separated list (without list markup) but can be customised to use different separators, and the linking can be disabled. The tags are output in the order they appear on the post, these can be reordered by dragging and dropping.\n\nThe `{{tags}}` helper does not output internal tags. This can be changed by passing a different value to the `visibility` attribute.\n\n### Example code\n\nThe basic use of the tags helper will output something like 'my-tag, my-other-tag, more-tagging' where each tag is linked to its own tag page:\n\n```\n{{tags}}\n```\n\nYou can customise the separator between tags. The following will output something like 'my-tag | my-other-tag | more tagging'\n\n```\n{{tags separator=\" | \"}}\n```\n\nAdditionally you can add an optional prefix or suffix. This example will output something like 'Tagged in: my-tag | my-other-tag | more tagging'\n\n```\n{{tags separator=\" | \" prefix=\"Tagged in:\"}}\n```\n\nYou can use HTML in the separator, prefix and suffix arguments. So you can achieve something like 'my-tag • my-other-tag • more tagging'.\n\n```\n{{tags separator=\" &bull; \"}}\n```\n\nIf you don't want your list of tags to be automatically linked to their tag pages, you can turn this off:\n\n```\n{{tags autolink=\"false\"}}\n```\n\nIf you want to output a fixed number of tags, you can add a `limit` to the helper. E.g. adding a limit of 1 will output just the first tag:\n\n```\n{{tags limit=\"1\"}}\n```\n\nIf you want to output a specific range of tags, you can use `from` and `to` either together or on their own. Using `to` will override the `limit` attribute. \n\nE.g. using from=\"2\" would output all tags, but starting from the second tag:\n\n```\n{{tags from=\"2\"}}\n```\n\nE.g. setting both from and to to `1` would do the same as limit=\"1\"\n\n`{{tags from=\"1\" to=\"1\"}}` is the same as `{{tags limit=\"1\"}}` \n\n\n## The `visibility` attribute\n\nAs of Ghost 0.9 posts, tags and users all have a concept of `visibility`, which defaults to `public`. The key feature build on this so far is Internal Tags, which are tags where the `visibility` is marked as `internal` instead of `public`. These tags will therefore not be output by the `{{tags}}` helper unless you specifically ask for them.\n\nBy default the `visibility` attribute is set to the string \"public\". This can be overridden to pass any other value, and if there is no matching value for `visibility` nothing will be output. E.g. you can set `visibility` to be \"internal\" to _only_ output internal tags. You can also pass a comma-separated list of values, or the value \"all\" to output all items.\n\n```\n{{tags visibility=\"all\"}}\n```\n\n### Advanced example\n\nIf you want to output your tags completely differently, you can fully customise the output by using the [foreach](doc:foreach) helper, instead of the tags helper. Here's an example of how to output list markup:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{{#post}}\\n  {{#if tags}}\\n    <ul>\\n    {{#foreach tags}}\\n      <li>\\n        <a href=\\\"{{url}}\\\" title=\\\"{{name}}\\\" class=\\\"tag tag-{{id}} {{slug}}\\\">{{name}}</a>\\n      </li>  \\n    {{/foreach}}\\n    </ul>\\n  {{/if}}\\n{{/post}}  \",\n      \"language\": \"handlebars\"\n    }\n  ]\n}\n[/block]\n**Note:** There's no need to switch between double and single quotes when writing HTML with handlebars. Double quotes can be used for both because the handlebars is executed first.\n\n### List of Attributes\n\n* **id** - the incremental ID of the tag\n* **name** - the name of the tag\n* **slug** - slugified version of the name (used in urls and also useful for class names)\n* **description** - a description of the tag\n* **image** - the cover image for the tag ([image helper](doc:image))\n* **meta_title** - the tag's meta title  ([meta_title helper](doc:meta_title))\n* **meta_description** - the tag's meta description ([meta_description helper](doc:meta_description))\n* **url** - the web address for the tag's page ([url helper](doc:url))","excerpt":"`{{tags}}` Helper - Output a formatted tag list","slug":"tags","type":"basic","title":"tags"}

tags

`{{tags}}` Helper - Output a formatted tag list

[block:html] { "html": "<div class=\"github-deeplinks\">\n <a href=\"https://github.com/TryGhost/Ghost/blob/0.10.0/core/server/helpers/tags.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/tags_spec.js\" class=\"fa fa-check-square-o fa-right\">Tests</a>\n</div>" } [/block] Usage: `{{tags}}` or `{{#foreach tags}}{{/foreach}}` in `tag.hbs` you can use `{{#tag}}{{/tag}}` to access tag properties [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": "* `separator` (string, default \", \")\n* `suffix` (string)\n* `prefix` (string)\n* `autolink` (boolean)\n* `limit` (number)\n* `from` (number)\n* `to` (number)\n* `visibility` (string, default \"public\")" }, "cols": 3, "rows": 1 } [/block] ### Description `{{tags}}` is a formatting helper for outputting a linked list of tags for a particular post. It defaults to a comma-separated list (without list markup) but can be customised to use different separators, and the linking can be disabled. The tags are output in the order they appear on the post, these can be reordered by dragging and dropping. The `{{tags}}` helper does not output internal tags. This can be changed by passing a different value to the `visibility` attribute. ### Example code The basic use of the tags helper will output something like 'my-tag, my-other-tag, more-tagging' where each tag is linked to its own tag page: ``` {{tags}} ``` You can customise the separator between tags. The following will output something like 'my-tag | my-other-tag | more tagging' ``` {{tags separator=" | "}} ``` Additionally you can add an optional prefix or suffix. This example will output something like 'Tagged in: my-tag | my-other-tag | more tagging' ``` {{tags separator=" | " prefix="Tagged in:"}} ``` You can use HTML in the separator, prefix and suffix arguments. So you can achieve something like 'my-tag • my-other-tag • more tagging'. ``` {{tags separator=" &bull; "}} ``` If you don't want your list of tags to be automatically linked to their tag pages, you can turn this off: ``` {{tags autolink="false"}} ``` If you want to output a fixed number of tags, you can add a `limit` to the helper. E.g. adding a limit of 1 will output just the first tag: ``` {{tags limit="1"}} ``` If you want to output a specific range of tags, you can use `from` and `to` either together or on their own. Using `to` will override the `limit` attribute. E.g. using from="2" would output all tags, but starting from the second tag: ``` {{tags from="2"}} ``` E.g. setting both from and to to `1` would do the same as limit="1" `{{tags from="1" to="1"}}` is the same as `{{tags limit="1"}}` ## The `visibility` attribute As of Ghost 0.9 posts, tags and users all have a concept of `visibility`, which defaults to `public`. The key feature build on this so far is Internal Tags, which are tags where the `visibility` is marked as `internal` instead of `public`. These tags will therefore not be output by the `{{tags}}` helper unless you specifically ask for them. By default the `visibility` attribute is set to the string "public". This can be overridden to pass any other value, and if there is no matching value for `visibility` nothing will be output. E.g. you can set `visibility` to be "internal" to _only_ output internal tags. You can also pass a comma-separated list of values, or the value "all" to output all items. ``` {{tags visibility="all"}} ``` ### Advanced example If you want to output your tags completely differently, you can fully customise the output by using the [foreach](doc:foreach) helper, instead of the tags helper. Here's an example of how to output list markup: [block:code] { "codes": [ { "code": "{{#post}}\n {{#if tags}}\n <ul>\n {{#foreach tags}}\n <li>\n <a href=\"{{url}}\" title=\"{{name}}\" class=\"tag tag-{{id}} {{slug}}\">{{name}}</a>\n </li> \n {{/foreach}}\n </ul>\n {{/if}}\n{{/post}} ", "language": "handlebars" } ] } [/block] **Note:** There's no need to switch between double and single quotes when writing HTML with handlebars. Double quotes can be used for both because the handlebars is executed first. ### List of Attributes * **id** - the incremental ID of the tag * **name** - the name of the tag * **slug** - slugified version of the name (used in urls and also useful for class names) * **description** - a description of the tag * **image** - the cover image for the tag ([image helper](doc:image)) * **meta_title** - the tag's meta title ([meta_title helper](doc:meta_title)) * **meta_description** - the tag's meta description ([meta_description helper](doc:meta_description)) * **url** - the web address for the tag's page ([url helper](doc:url))