Starting with build 2144, Vici MVC supports pluggable view engines. This means you can write your own view engine and use it with Vici MVC.
As everyone knows by now, Ruby is one of the hottest programming languages around, so deciding on a new view engine for Vici MVC was a no-brainer. Obviously, IronRuby was the best choice because of the tight integration with the .NET Framework.
That's it. Now you can simply create a template using IronRuby as the scripting language. You only have to name the views "*.rb.htm".
For example:
<html> <body> <table> <tr><th>Row</th><th>Description</th></tr> <% 1.upto(10) do |x| %> <tr><td><%= x %></td><td>This is a description for row <%= x %></td></tr> <% end %> </table> </body> </html>
Of course you can use ViewData variables just like in "normal" Vici MVC templates. Simply refer to them by name:
<html> <body> <h1>Users</h1> <table> <tr><th>Name</th><th>E-mail address</th></tr> <% users.each do |user| %> <tr><td><%= user.Name %></td><td><%= user.EMail %></td></tr> <% end %> </table> </body> </html>
You should make sure you stick to Ruby's naming conventions, meaning that variables should not start with an uppercase character. You're also allowed to use "_" delimited variables. The view engine will map this to mixed case when looking up variables in the viewdata collection.
Vici MVC has a few built-in variables that start with a "@". In Ruby these kind of variables are reserved for instance variables, so these have to be written as _varname.
Examples:
| .NET Variable (ViewData) | Ruby variable(s) | |
|---|---|---|
| User | user | |
| user | user | |
| userName | userName or user_name | |
| UserName | userName or user_name | |
| @View | _view | |
More documentation will follow