spark view engine
DESCRIPTION
Slides from Spark talk at Raleigh Code Camp 2009TRANSCRIPT
![Page 2: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/2.jpg)
What is Spark View Engine?
A view engine for ASP.NET MVC and Castle MonoRail that gives you the full capabilities of C# (and other languages) within your views via an HTML-friendly syntax
![Page 3: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/3.jpg)
Who is this presentation for?
![Page 4: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/4.jpg)
Who is this presentation for?
Web Developers...
• ...that use MVC, but want to switch view engines
![Page 5: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/5.jpg)
Who is this presentation for?
Web Developers...
• ...that use MVC, but want to switch view engines• ...that know about Spark, but have been apprehensive about
using it
![Page 6: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/6.jpg)
Who is this presentation for?
Web Developers...
• ...that use MVC, but want to switch view engines• ...that know about Spark, but have been apprehensive about
using it• ...that use other view engines like nHaml or nVelocity, but
want to learn more about Spark
![Page 7: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/7.jpg)
Who is this presentation for?
Web Developers...
• ...that use MVC, but want to switch view engines• ...that know about Spark, but have been apprehensive about
using it• ...that use other view engines like nHaml or nVelocity, but
want to learn more about Spark• ...that just haven't had the time to sit down and learn Spark
![Page 8: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/8.jpg)
...until now!
![Page 9: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/9.jpg)
Agenda
1. History of Spark2. Getting Started3. Basic Concepts4. Advanced Concepts5. Gotchas 6. References7. Wrap-up
![Page 10: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/10.jpg)
Introducing Spark - History
http://haacked.com/archive/2008/05/03/code-based-repeater-for-asp.net-mvc.aspx#67579
![Page 11: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/11.jpg)
Getting Started With Spark
![Page 12: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/12.jpg)
Getting Started
• Create/Open an MVC project • Reference Spark.dll and Spark.Mvc.dll• Configure the view engine• Start using it!
![Page 13: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/13.jpg)
Basic Concepts
![Page 14: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/14.jpg)
Basic Concepts
Layouts• Layouts\Application.Spark• Shared\Application.Spark• View() method• <use master="layout" />
![Page 15: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/15.jpg)
Basic Concepts
Named Content• <use content="" />• <content name=""></content>,
<content:name></content:name>
![Page 16: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/16.jpg)
Basic Concepts
Partials• <use file="" />• <Partial someVar="" />
![Page 17: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/17.jpg)
Basic Concepts
• Variableso <var [var name]="[value]" type="[type]" /> or defo <global [var name]="[value]" type="[type]" />o <set [var name]="[value]" />
• ViewData o <viewdata key="type" />
![Page 18: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/18.jpg)
Basic Concepts
_global.Spark• Special partial that gets auto-included in a Spark file if it is in
the layout folder or the root folder of the view• Great place to put <using> statements, global variables, or
other elements that do not immediately write to the output buffer
![Page 19: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/19.jpg)
Basic Concepts
Control-of-flow statements• <test> statement, <if><else>• <for>• Attributes on html elements
![Page 20: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/20.jpg)
Advanced Concepts
![Page 21: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/21.jpg)
Advanced Concepts
Inline C#• Use # to delimit any plain ol' C# code
![Page 22: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/22.jpg)
Advanced Concepts
Macros• Functions/Methods that take arguments and return strings
![Page 23: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/23.jpg)
Advanced Concepts
These items are beyond this introductory presentation, but Spark supports them:• Caching of views (partial caching included)• Precompilation of view classes• Descriptor Filters for differentiating views based on things
like area, theme, or locale
![Page 24: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/24.jpg)
Gotchas
1. Intellisense not working for some types like Html (helpers)o The background compiler for Spark isn't finding the
assemblieso Copy the assemblies local to resolve
– R#'s intellisense doesn't work with Spark. o If using R# and Spark, change R#'s intellisense setting to
use Visual Studio'so Don't use the <namespaces> section in the web.config
file. Use the <using> syntax in the _global.Spark file instead.
![Page 25: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/25.jpg)
References and Links
1. http://www.sparkviewengine.com2. http://www.whereslou.com3. http://www.github.com/loudej/spark4. http://www.dimecasts.net
![Page 26: Spark View Engine](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bc6b8d4a7959fa268b45ff/html5/thumbnails/26.jpg)
Holla@me
Thank you for your time and attention!
Curtis Mitchellt: @curtis_mitchelle: [email protected]: http://www.curtismitchell.com
http://speakerrate.com/talks/1468