Skip to content

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Dec 3, 2020

  • Add two properties to the Property class: isEmptyIterable and renderIterable which are used for sections and inverted sections.
  • Make all Properties of the right type again, avoiding all of the casts. This involved a weird arrangement though: now every propertyMap has at least one type parameter, CT_ (for context type). The propertyMap on a generic type will also have the other generics, for example propertyMap<E, CT_> for Renderer_List, and propertyMap<K, V, CT_> for Renderer_Map. This allows us to spread in inherited properties, like Object's hashMap. The propertyMap for Foo_Renderer cannot claim that the Property representing hashCode has functions that take Foo instances; they only take Object. By introducing CT_, we can say that Foo_Renderer's propertyMap spreads in Object_Renderer's propertyMap as propertyMap<Foo>().

@google-cla google-cla bot added the cla: yes Google CLA check succeeded. label Dec 3, 2020
rendererClassesArePublic: rendererClassesArePublic)
._buildTemplateRenderers(specs);
return DartFormatter().format(raw.toString());
}

/// This class builds runtime Mustache renderers from a set of [RendererSpec]s.
class RuntimeRenderersBuilder {
static const _contextTypeVariable = 'CT_';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice


if (property.isPrivate || property.isStatic || property.isSetter) return;
_buffer.writeln("'${property.name}': Property(");
_buffer
.writeln('getValue: (Object c) => (c as $typeName).${property.name},');
.writeln('getValue: ($_contextTypeVariable c) => c.${property.name},');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. It seemed like something like this should have been possible!

@srawlins srawlins merged commit 067c661 into dart-lang:master Dec 3, 2020
@srawlins srawlins deleted the mustachio-7 branch December 3, 2020 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants