Add index-as test

This commit is contained in:
Tobe O 2018-06-27 19:54:43 -04:00
parent f811dfcd80
commit 5a7eccbcb8
3 changed files with 18 additions and 8 deletions

View file

@ -8,17 +8,27 @@
<excludeFolder url="file://$MODULE_DIR$/angel_jael/build" />
</content>
<content url="file://$MODULE_DIR$/build_jael">
<excludeFolder url="file://$MODULE_DIR$/build_jael/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/build_jael/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build_jael/build" />
</content>
<content url="file://$MODULE_DIR$/dsx" />
<content url="file://$MODULE_DIR$/dsx_generator" />
<content url="file://$MODULE_DIR$/dsx">
<excludeFolder url="file://$MODULE_DIR$/dsx/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/dsx/.pub" />
<excludeFolder url="file://$MODULE_DIR$/dsx/build" />
</content>
<content url="file://$MODULE_DIR$/dsx_generator">
<excludeFolder url="file://$MODULE_DIR$/dsx_generator/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/dsx_generator/.pub" />
<excludeFolder url="file://$MODULE_DIR$/dsx_generator/build" />
</content>
<content url="file://$MODULE_DIR$/jael">
<excludeFolder url="file://$MODULE_DIR$/jael/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/jael/.pub" />
<excludeFolder url="file://$MODULE_DIR$/jael/build" />
</content>
<content url="file://$MODULE_DIR$/jael_preprocessor">
<excludeFolder url="file://$MODULE_DIR$/jael_preprocessor/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/jael_preprocessor/.pub" />
<excludeFolder url="file://$MODULE_DIR$/jael_preprocessor/build" />
</content>

View file

@ -173,8 +173,8 @@ class Renderer {
.firstWhere((a) => a.name == 'index-as', orElse: () => null);
var alias = asAttribute?.value?.compute(scope) ?? 'item';
var indexAs = indexAsAttribute?.value?.compute(scope)?.toString() ?? 'item';
var otherAttributes =
element.attributes.where((a) => a.name != 'for-each' && a.name != 'as');
var otherAttributes = element.attributes.where(
(a) => a.name != 'for-each' && a.name != 'as' && a.name != 'index-as');
Element strippedElement;
if (element is SelfClosingElement)

View file

@ -99,7 +99,7 @@ main() {
<body>
<h1>Pokémon</h1>
<ul>
<li for-each=starters as="starter">{{ starter.name }} - {{ starter.type }}</li>
<li for-each=starters as="starter" index-as="idx">#{{ idx }} {{ starter.name }} - {{ starter.type }}</li>
</ul>
</body>
</html>
@ -124,13 +124,13 @@ main() {
</h1>
<ul>
<li>
Bulbasaur - Grass
#0 Bulbasaur - Grass
</li>
<li>
Charmander - Fire
#1 Charmander - Fire
</li>
<li>
Squirtle - Water
#2 Squirtle - Water
</li>
</ul>
</body>