1 | var exports = module.exports;
|
2 |
|
3 | /**
|
4 | * Used within an <code data-language="swig">{% if %}</code> tag, the code block following this tag up until <code data-language="swig">{% endif %}</code> will be rendered if the <i>if</i> statement returns false.
|
5 | *
|
6 | * @alias else
|
7 | *
|
8 | * @example
|
9 | * {% if false %}
|
10 | * statement1
|
11 | * {% else %}
|
12 | * statement2
|
13 | * {% endif %}
|
14 | * // => statement2
|
15 | *
|
16 | */
|
17 | exports.compile = function () {
|
18 | return '} else {\n';
|
19 | };
|
20 |
|
21 | exports.parse = function (str, line, parser, types, stack) {
|
22 | parser.on('*', function (token) {
|
23 | throw new Error('"else" tag does not accept any tokens. Found "' + token.match + '" on line ' + line + '.');
|
24 | });
|
25 |
|
26 | return (stack.length && stack[stack.length - 1].name === 'feature');
|
27 | };
|