edwindj/whisker — pull request #11 by KentonWhite (2014-02-25 21:01:11+00:00)
Title: Support R variables with . and data.frames with $

I was incorporating whisker into ProjectTemplate at a user request and was having problems handling variables that have '.' in their name as well as referencing columns of a data.frame using the '$' notation.

Sure enough, in the code there was a TODO about this!

The code looks like it is splitting variables on '.' to create nested object method calls. E.g if I pass in `"foo.bar"` the variable name is `foo` and the method name to call on `foo` is `bar`. To the best of my knowledge, method calls on objects in R don't use '.'.

The common use cases that I'm aware of are using '$' to reference a column of data on a data.frame and using '@' to access a slot on an object. I've updated the code to handle variable names with '.' and to handle the '$' on data.frames. E.g. if I pass in `"foo$bar"` it will take the variable name to be `foo` and the column to return as `bar`. If I pass `"foo.bar"` it will take the variable name to be `foo.bar`.

I didn't make changes for the slots, but made a TODO note.