Closed caoer closed 8 years ago
Hello @caoer.
GRMustache is a template rendering engine: once a template has been rendered with the data you provide, its job is done:
// Render a HTML string
NSString *html = [GRMustacheTemplate render:...];
It will render {{ name.firstName }}
fine. In an NSString. And NSString does not automagically update itself when your data is updated.
You need to provide your own runtime to get the behavior you need.
hi @groue, thanks for your respond. Can you share some thoughts on how to provide my own runtime? If possible, I'd like to use GRMustache's code if possible. Best if I can hack into it's code and add such functionality. For example, once a string rendering is done, it reports how many variable are renderred and what are them. I've looked at GRMustacheTag, seems like the place to start?
Remember to keep it simple. Mustache is a rendering engine. Not a runtime.
for example, my template is
{{name}}
,{{ name.firstName}}
, the context is{ "name": {"firstName": "cc"}}
. How can I extract the variable name? My use case is that I want to watch for context's data change, if name.firstName is changed, the view will be updated.