You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an object or struct is passed to a template, you can generally access the properties on the object/struct by using {{ objectName.propertyName }}. However, this appears not to work with computed properties.
In other words, with a class like:
classfoo{varbar:String={return"baz"}}
If you instantiate a foo, put it in the context dictionary, and then try to print {{ foo.bar }} in the template, nothing prints.
In my actual code, I didn't want my bar value to be an actual normal property calculated when init-ing the struct, so I ended up working around it by implementing bar as a Stencil filter.
The text was updated successfully, but these errors were encountered:
Swift Mirror does not support computed properties, it is used to lookup properties of swift types. If you use NSObject-based types KVO will be used. There is no workaround for that, as far as I know. You could though define an extension on your type that creates a context dictionary that you use in Stencil instead of accessing properties, but that's far from a good solution.
If an object or struct is passed to a template, you can generally access the properties on the object/struct by using
{{ objectName.propertyName }}
. However, this appears not to work with computed properties.In other words, with a class like:
If you instantiate a
foo
, put it in the context dictionary, and then try to print{{ foo.bar }}
in the template, nothing prints.In my actual code, I didn't want my
bar
value to be an actual normal property calculated when init-ing the struct, so I ended up working around it by implementingbar
as a Stencil filter.The text was updated successfully, but these errors were encountered: