Total Complexity | 3 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | |||
3 | """Provides custom extension, exposing a ``foobar`` filter.""" |
||
4 | |||
5 | from jinja2.ext import Extension |
||
6 | from cookiecutter.utils import simple_filter |
||
7 | |||
8 | |||
9 | class FoobarExtension(Extension): |
||
10 | """Simple jinja2 extension for cookiecutter test purposes.""" |
||
11 | |||
12 | def __init__(self, environment): |
||
13 | """Foobar Extension Constructor.""" |
||
14 | super(FoobarExtension, self).__init__(environment) |
||
15 | environment.filters['foobar'] = lambda v: v * 2 |
||
16 | |||
17 | |||
18 | @simple_filter |
||
19 | def simplefilterextension(v): |
||
20 | """Provide a simple function-based filter extension.""" |
||
21 | return v.upper() |
||
22 |