This project is read-only.
Sharpy allows 2 ways of specifying the master page. Both are similar to the way master pages work with the default MVC view engine.

Specifying the master page in the view

The default way of specifying a master page is to do so in the first line in the view.

{master file='~/Views/Shared/Master.sharpy' title='Index'}

The master function has a single required attribute to specify the file to be used. Any additional attributes will be evaluated and stored as variables. These variables will be available in both the master page and the rest of the view.

The rest of the view will now be evaluated and the result will be assigned to a variable called 'content' which will be available in the master page.

<html xmlns="" >

Specifying the master page in the controller

The master page can also be specified as the second argument when returning View() as the ActionResult from your controller.

public ActionResult Index()
    return View("Index", "Master");

If the master page is specified in both the controller and the view the master page specified in the controller will take preference. This is similar to the behavior in the default MVC view engine.

Last edited Feb 18, 2010 at 10:29 AM by JacoPretorius, version 2


No comments yet.