{"id":15023268,"url":"https://github.com/fffunction/nunjucks-capture","last_synced_at":"2025-10-26T23:30:30.421Z","repository":{"id":57312392,"uuid":"46567796","full_name":"fffunction/nunjucks-capture","owner":"fffunction","description":"📝 A nunjucks port of Liquids capture tag","archived":false,"fork":false,"pushed_at":"2020-06-03T09:18:15.000Z","size":229,"stargazers_count":1,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T06:32:09.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/fffunction.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}},"created_at":"2015-11-20T14:50:17.000Z","updated_at":"2017-07-07T16:03:39.000Z","dependencies_parsed_at":"2022-09-16T01:54:04.712Z","dependency_job_id":null,"html_url":"https://github.com/fffunction/nunjucks-capture","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffunction%2Fnunjucks-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffunction%2Fnunjucks-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffunction%2Fnunjucks-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffunction%2Fnunjucks-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fffunction","download_url":"https://codeload.github.com/fffunction/nunjucks-capture/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238408627,"owners_count":19467139,"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-09-24T19:58:53.474Z","updated_at":"2025-10-26T23:30:30.136Z","avatar_url":"https://github.com/fffunction.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nunjucks-capture\n\n\u003e A nunjucks port of the [Liquid Capture tag](https://docs.shopify.com/themes/liquid-documentation/tags/variable-tags#capture)\n\n[![Build Status](https://travis-ci.org/fffunction/nunjucks-capture.svg?branch=master)](https://travis-ci.org/fffunction/nunjucks-capture) [![Coverage Status](https://coveralls.io/repos/fffunction/nunjucks-capture/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/fffunction/nunjucks-capture?branch=master) \n[![Greenkeeper badge](https://badges.greenkeeper.io/fffunction/nunjucks-capture.svg)](https://greenkeeper.io/)\n\n## Install\n\n```sh\nnpm install nunjucks-capture\n```\n\n## Usage\n\nAdd the extension to the Nunjucks environment:\n\n```js\nvar nunjucks = require('nunjucks');\nvar CaptureTag = require('nunjucks-capture');\n\nvar env = new nunjucks.Environment();\nenv.addExtension('CaptureTag', new CaptureTag());\n```\n\nCapture some content as a string:\n\n```html+jinja\n{% capture as=\"demo\" -%}\n    \u003ch2\u003eHello, world!\u003c/h2\u003e\n    {% include 'includes/content.html' %}\n{%- endcapture %}\n\n{{ demo }}\n\n\u003cpre\u003e\n    {{ demo | e }}\n\u003c/pre\u003e\n\n```\n\nwill result in:\n\n```html\n\u003ch2\u003eHello, world!\u003c/h2\u003e\n\u003cp\u003eThis is the included content\u003c/p\u003e\n\u003cpre\u003e\n    \u0026lt;h2\u0026gt;Hello, world!\u0026lt;/h2\u0026gt;\n    \u0026lt;p\u0026gt;This is the included content\u0026lt;/p\u0026gt;\n\u003c/pre\u003e\n```\n\nEverything between the two tags is stored in a new variable as a string. Dynamic content, such as includes or loops, are evaluated before the variable is stored. This means you've captured the resulting content, not the templating.\n\nSee also:\n    - [Nunjucks API documentation](https://mozilla.github.io/nunjucks/api.html)\n    - [Nunjucks templating documentation](https://mozilla.github.io/nunjucks/templating.html)\n\n[![Built by fffunction, with love and coffee](http://i.imgur.com/hY7NBej.png)](http://fffunction.co \"Built by fffunction, with love and coffee\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffffunction%2Fnunjucks-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffffunction%2Fnunjucks-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffffunction%2Fnunjucks-capture/lists"}