ViewComponents
Brail supports the following syntax for ViewComponents:
<% component MyViewComponent %>
The above will call MyViewComponent and send any output from the component to the browser.
You can also use view components with arguments. Those arguments are passed via a dictionary (Hash table), like this:
<% component MyViewComponentWithParams, {"arg" : "value" } %>
If you want to pass a body to the component, just use the normal colon + indnet to do so:
<% component MyViewComponentWithBody: %> html content that will be sent to the user if the component will call the RenderBody() method <% end %>
The contents of a component is evaluated when you call RenderBody, so if you will call RenderBody multiple times, you will send the output of the component's body multiple times as well.
You can also use sections in Brail. Sections are what a way to pass templates to the component in a fine grained manner. Here is a simple example:
<% component Grid: section Header: %> <th>Id</th> <th>Name</th> <% end section Item: %> <td>${item.Id}</td> <td>${item.Name}</td> <% end end %>