Completed
Push — master ( 376d77...59bfb2 )
by
unknown
01:07
created

HelloExtension.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
# -*- coding: utf-8 -*-
2
3
from jinja2 import nodes
4
from jinja2.ext import Extension
5
6
7
class HelloExtension(Extension):
8
    tags = set(['hello'])
9
10
    def __init__(self, environment):
11
        super(HelloExtension, self).__init__(environment)
12
13
    def _hello(self, name):
14
        return 'Hello {name}!'.format(name=name)
15
16
    def parse(self, parser):
17
        lineno = next(parser.stream).lineno
18
        node = parser.parse_expression()
19
        call_method = self.call_method('_hello', [node], lineno=lineno)
20
        return nodes.Output([call_method], lineno=lineno)
21