1.1.0 • Published 10 days ago

twig-markdown v1.1.0

Weekly downloads
119
License
MIT
Repository
github
Last release
10 days ago

Twig.js Markdown

{% markdown %} tag support for Twig templates using twig.js and marked compiler. Compatible with gulp-twig.

<div class="content">
    <div>
        {% markdown %}
            # Embed markdown directly in your template…
        {% endmarkdown %}
    </div>
    <div>
        {% markdown '../or/embed/external/file.md' %}{% endmarkdown %}
    </div>
    <div>
        {% apply markdown_to_html %}
            # Title
        {% endapply %}
    </div>
    <div>
        {% set content = '# Title' %}
        {{ content|markdown_to_html }}
    </div>
</div>

Install

npm install twig-markdown --save

Use

In TypeScript:

import * as twig from 'twig';
import twigMarkdown from 'twig-markdown';
twig.extend(twigMarkdown);
const template = twig.twig({ data: "{% markdown %}# Foo{% endmarkdown %}" });
template.render();

In JavaScript:

const twigMarkdown = require('twig-markdown');
const twig = require('twig');
twig.extend(twigMarkdown);
const template = twig.twig({ data: "{% markdown %}# Foo{% endmarkdown %}" });
template.render();

In javascript with gulp-twig plugin:

const twigMarkdown = require('twig-markdown');
const twigFoo = require('twig-foo');
const twig = require('gulp-twig');

// With only markdown extension.
twig({data: {}, extend: twigMarkdown});

// With multiple extensions.
twig({data: {}, extend: function(Twig){
    twigMarkdown(Twig);
    twigFoo(Twig);
}});

Contribute

Install npm dependencies and you're good to go, assuming you also have globally typescript:

npm install

Test with mocha:

npm test

Run build in watch mode:

npm start
1.1.0

10 days ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago