razor and the art of templating

Post on 18-Dec-2014

3.246 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

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!

TRANSCRIPT

Razor and the Art of Templating

Jess ChadwickTeam Lead / Architect / RIA Specialist

blog.jesschadwick.com@jchadwick

jesschadwick@gmail.com

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?

The Razor View

Lifecycle

top related