Socket
Socket
Sign inDemoInstall

nunjucks-capture

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nunjucks-capture

A nunjucks port of the Liquid Capture tag


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
7.88 kB
Created
Weekly downloads
 

Readme

Source

nunjucks-capture

A nunjucks port of the Liquid Capture tag

Build Status Coverage Status

Install

npm install nunjucks-capture

Usage

Add the extension to the Nunjucks environment:

var nunjucks = require('nunjucks');
var CaptureTag = require('nunjucks-capture');

var env = new nunjucks.Environment();
env.addExtension('CaptureTag', new CaptureTag());

Capture some content as a string:

{% capture as="demo" -%}
    <h2>Hello, world!</h2>
    {% include 'includes/content.html' %}
{%- endcapture %}

{{ demo }}

<pre>
    {{ demo | e }}
</pre>

will result in:

<h2>Hello, world!</h2>
<p>This is the included content</p>
<pre>
    &lt;h2&gt;Hello, world!&lt;/h2&gt;
    &lt;p&gt;This is the included content&lt;/p&gt;
</pre>

Everything 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.

See also: - Nunjucks API documentation - Nunjucks templating documentation

Built by fffunction, with love and coffee

Keywords

FAQs

Last updated on 04 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc