Upload
jess-chadwick
View
3.246
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Though I deliberately went easy on the slides and heavy on the code, there might be a few nuggets in here so I'm posting it anyway. Enjoy!
Citation preview
Razor and the Art of Templating
Jess ChadwickTeam Lead / Architect / RIA Specialist
blog.jesschadwick.com@jchadwick
Razor basicsRazor & ASP.NET MVCExtending Razor
Agenda
What is Razor?
What is Razor?
A New View
View
Controller
Model
Simplicity &
Elegance
Code & Markup
DEMOASPX vs. Razor
Creating Views
1. Combine code and markup Don’t think about it
2. @ indicates a code block
3. Standard language keywordse.g. foreach, using, inherits, etc.
Basic Syntax: 3 Simple Rules
Create a main site layout(think “Master Page”)
Implement content of each page in sections Think ContentPlaceHolder RenderBody() RenderSection()
Designing a Site Layout
functions keyword defines a code section(think <script runat=“server”>)
helper keyword defines a reusable Razor section
Functions and Helpers
Razor and ASP.NET MVCLike peanut butter and chocolate
model
New Keyword:
Pause… Time out.It’s gonna get scary.
The Razor APIDiving deeper…
Engine
The Razor API
Parser Generator
Host
Code + Markup
Parsed Document
Code Compile
Unit.NET Class
Lifecycle of a Razor Template
Questions / Comments?
My blog: blog.jesschadwick.com
RazorPad: razorpad.codeplex.com
Razor Syntax Tutorial:http://www.asp.net/webmatrix/tutorials/2-introduction-to-asp-net-web-programming-using-the-razor-syntax
Resources
The Razor View
Lifecycle