Skip to content

Commit

Permalink
Sync 0.6.0-dev.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ykmnkmi committed Jan 27, 2024
1 parent 9ec5e52 commit a64f5c9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.6.0-dev.11
## 0.6.0-dev.12
- internal changes.
- `chrome` platform tests.
- added:
Expand Down
6 changes: 5 additions & 1 deletion lib/src/renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ base class StringSinkRenderer
if (remaining.remove(key)) {
derived.set(key, named[key]);
} else {
derived.set(key, defaultValue.accept(this, context));
if (defaultValue is Name) {
derived.set(key, named[defaultValue.name]);
} else {
derived.set(key, defaultValue.accept(this, context));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: jinja
version: 0.6.0-dev.11
version: 0.6.0-dev.12
description: >-
Jinja2 template engine for Dart.
Variables, expressions, control structures and template inheritance.
Expand Down
5 changes: 2 additions & 3 deletions test/statements/macro_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ void main() {
expect(tmpl.render(), equals('5|4|3|2|1'));
});

// TODO(macro): fix this test
test('macro defaults self ref', () {
var tmpl = env.fromString('''
{% set x = 42 %}
{% macro m(a, b=x, x=23) %}{{ a }}|{{ b }}|{{ x }}{% endmacro -%}
{{ m(1) }},{{ m(1, b=2) }},{{ m(1, b=2, x=3) }},{{ m(1, x=7) }}''');
expect(tmpl.render(), equals('"1||23,1|2|23,1|2|3,1|7|7"'));
}, skip: 'Not implemented.');
expect(tmpl.render(), equals('1||23,1|2|23,1|2|3,1|7|7'));
});
});
}
4 changes: 1 addition & 3 deletions test/statements/set_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ void main() {
return value;
}

var env = Environment(
filters: {'myfilter': myfilter},
trimBlocks: true);
var env = Environment(filters: {'myfilter': myfilter}, trimBlocks: true);
var tmpl = env.fromString('{% set a = " xxx " %}'
'{% set foo | myfilter(a) | trim | length | string %}'
' {% set b = " yy " %} 42 {{ a }}{{ b }} '
Expand Down

0 comments on commit a64f5c9

Please sign in to comment.