Home | Photography | Flickr | LiveJournal | Get Firefox

Smarty: repeating blocks

In a future version of Smarty, blocks will be repeatable. According to the current CVS repository, a block function will take an optional forth parameter which will be passed as a reference and set to "false" by default. If, in the course of the function execution it is set to "true", this will be detected and the block will be run again. It will be up to the block function to iterate through the data properly and set the repeat flag to "false" when the data has been exhausted. The first iterance of any block function will have a NULL content parameter (as it does today). At this point, the function should setup all of the needed information to iterate through the data. Each subsequent call will pass the pre-parsed content as the content parameter. This means each iteration will be set with data reflecting the previous iterations variable assignments. And each iteration is reponsible for preparing the variable assignments for the NEXT iteration. On the final iteration, the function should set the repeat flag to "false" and clean up after itself as it will not be called again. [via Eadz::Blog]

I've been waiting for this feature for a while and wondering why it wasn't in Smarty before.

Share and Enjoy:
  • Facebook
  • StumbleUpon
  • Digg
  • e-mail
  • del.icio.us
  • Google
  • Reddit
  • Technorati
  • BlinkList
  • blogmarks
  • Blue Dot
  • description
  • Furl
  • Ma.gnolia
  • MisterWong
  • Netvouz
  • PlugIM
  • Propeller
  • Simpy
  • Spurl
  • TailRank

Trackbacks

close Reblog this comment
blog comments powered by Disqus