Thursday, July 2, 2009

Wax Templating Engine

Like most frameworks, Wax makes use of a templating engine to make views easier to create. However, unlike other frameworks (like rails and CakePHP), Wax does not allow any embedded PHP code. Instead, Wax gives you the functionality to create new tags and interface directly with the view in the code. For example, if you had (in rails) a partial named _post.html.erb that rendered a single blog post, you would create a loop inside the view that rendered data from the model. Rather than trying to put logic like this in the view files, you could instead create a new tag. Within the view file, you would then put <Posts />. From the code, you register the tag name and it's corresponding class name (essentially a model). From this class, the data can be rendered in place of the Posts tag. Examples and more details are soon to come, since I still need to figure out a specific process for passing data like this. Update 7/30/09: Nevermind, I gave in to embedded PHP code.

No comments:

Post a Comment