Template global fixes #247

merged 3 commits into from May 19, 2012

5 participants

SilverStripe Ltd. member

@hafriedlander - this is one for you to review. The TemplateGlobalProvider didn't let you create objects. I have attempted to solve that it and it both seems to work and passes the tests, but should probably still review it.

It means that we can make $Now a template global, and still have $Now.Year work.

sminnee added some commits Mar 16, 2012
@sminnee sminnee BUGFIX: Allow template globals to be used in both object and value co…
…ntexts (e.g. $Now.Year)

BUGFIX: Allow template globals to return objects as well as values.
@sminnee sminnee API CHANGE: Rename 'PastMember' to 'IsRepeatMember' in templates.
API CHANGE: Move Controller::PastMember() to Member::is_repeat_member() in code.
API CHANGE: Removed Controller::CurrentMember(), it was only ever intended as a template global provider.
@sminnee sminnee API CHANGE: Remove Controller::Now(), as it was only ever a template …
…global provider, and use the new TemplateGlobalProvider interface on SS_Datetime instead.
SilverStripe Ltd. member

I'm sneaking in here and got immediately confused about the name. Throwing some suggestions out here to satisfy my inner demons.

  • Member::is_member()
  • Member::has_account()
  • Member::has_previous_logged_in()
SilverStripe Ltd. member

"Has previously logged in" is probably the one that is most accurate. It's verbose, but it's also a bit of an edge-case feature, so maybe that's okay?

Most likely. After three years with SS; I never used that call. ;)

SilverStripe Ltd. member

Hmm. Looks ok. Don't really like "getObj" as a name, but can't think of something better, given the copy-pasta needed to make _DataPresenter override obj itself. Only thing to check is that if a DataObject has a getObj method then $Obj works - I think it should, but best to check.

SilverStripe Ltd. member

I might rename the method to something else. I'll add a test for the edge case you suggest.

SilverStripe Ltd. member

@sminnee Can you try to get those tests written (and the method renamed) this week so we can still get this pull request into beta2?

SilverStripe Ltd. member

@sminnee @hafriedlander Are you OK with merging this in without tests? Unless Sam can write them in the next ~10h I don't see how that'd get into beta2 :)

SilverStripe Ltd. member

Umm. It looks OK? It need rechecking against the changes I made last week re: passing arguments into includes to make sure tests still pass.

SilverStripe Ltd. member

It'd be great to get this in before beta3.

@halkyon halkyon added a commit that referenced this pull request May 19, 2012
@halkyon halkyon Merge branch (pull request #247) 'template-global-fixes' of https://g…
…ithub.com/sminnee/sapphire into sminnee-template-global-fixes
@halkyon halkyon merged commit 8bbfa97 into silverstripe:master May 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment