際際滷

際際滷Share a Scribd company logo
Ignite your ASP.NET MVC Applications with Spark View Engine t: @curtis_mitchell e: curtismitchell@gmail.com
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
Who is this presentation for?
Who is this presentation for? Web Developers... ...that use MVC, but want to switch view engines
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
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
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
...until now!
Agenda History of Spark Getting Started Basic Concepts Advanced Concepts Gotchas  References Wrap-up
Introducing Spark - History http://haacked.com/archive/2008/05/03/code-based-repeater-for-asp.net-mvc.aspx#67579
Getting Started With Spark
Getting Started Create/Open an MVC project  Reference Spark.dll and Spark.Mvc.dll Configure the view engine Start using it!
Basic Concepts
Basic Concepts Layouts Layouts\Application.Spark Shared\Application.Spark View() method <use master=&quot;layout&quot; />
Basic Concepts Named Content 油 <use content=&quot;&quot; /> <content name=&quot;&quot;></content>, <content:name></content:name>
Basic Concepts Partials <use file=&quot;&quot; /> <Partial someVar=&quot;&quot; />
Basic Concepts Variables <var [var name]=&quot;[value]&quot; type=&quot;[type]&quot; /> or def <global [var name]=&quot;[value]&quot; type=&quot;[type]&quot; /> <set [var name]=&quot;[value]&quot; />  ViewData油 <viewdata key=&quot;type&quot; />
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
Basic Concepts Control-of-flow statements <test> statement, <if><else> <for> Attributes on html elements
Advanced Concepts
Advanced Concepts Inline C# Use # to delimit any plain ol' C# code
Advanced Concepts Macros 油 Functions/Methods that take arguments and return strings
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
Gotchas Intellisense not working for some types like Html (helpers) The background compiler for Spark isn't finding the assemblies Copy the assemblies local to resolve R#'s intellisense doesn't work with Spark. 油 If using R# and Spark, change R#'s intellisense setting to use Visual Studio's Don't use the <namespaces> section in the web.config file.油 Use the <using> syntax in the _global.Spark file instead.
References and Links http://www.sparkviewengine.com http://www.whereslou.com http://www.github.com/loudej/spark http://www.dimecasts.net
[email_address] Thank you for your time and attention! 油 油 Curtis Mitchell t: @curtis_mitchell e: curtismitchell@gmail.com b: http://www.curtismitchell.com 油 http://speakerrate.com/talks/1468 油

More Related Content

What's hot (19)

A Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NETA Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NET
Harish Ranganathan
Using Ap Div Tag
Using Ap Div TagUsing Ap Div Tag
Using Ap Div Tag
Sutinder Mann
Keywords used in javascript
Keywords used in javascriptKeywords used in javascript
Keywords used in javascript
Max Friel
1.2 elements and attributes copy (3)
1.2 elements and attributes   copy (3)1.2 elements and attributes   copy (3)
1.2 elements and attributes copy (3)
Bulldogs83
Block2 Session2 Presentation
Block2 Session2 PresentationBlock2 Session2 Presentation
Block2 Session2 Presentation
Michael Gwyther
PHP Basics for Designers
PHP Basics for DesignersPHP Basics for Designers
PHP Basics for Designers
Matthew Turland
Client side rendering using mustache.js
Client side rendering using mustache.jsClient side rendering using mustache.js
Client side rendering using mustache.js
Bhashkar Sharma
HTML Introduction
HTML IntroductionHTML Introduction
HTML Introduction
Paul Dionysius
Javascript
JavascriptJavascript
Javascript
Iblesoft
29 Jsp
29 Jsp29 Jsp
29 Jsp
DSKUMAR G
Creating Content With Shortcodes
Creating Content With ShortcodesCreating Content With Shortcodes
Creating Content With Shortcodes
Jon Bishop
Ng talk
Ng talkNg talk
Ng talk
Aymene Bennour
Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
Sugree Phatanapherom
Selenium Interpreter
Selenium InterpreterSelenium Interpreter
Selenium Interpreter
melbournepatterns
Joomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design PresentationJoomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design Presentation
Chris Davenport
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
Andy Wallace
HTML Semantic Elements
HTML Semantic ElementsHTML Semantic Elements
HTML Semantic Elements
Reema
Customize Your Website With HTML5 and CSS3:
Customize Your Website With HTML5 and CSS3:Customize Your Website With HTML5 and CSS3:
Customize Your Website With HTML5 and CSS3:
Reema
Html5: What is it?
Html5: What is it? Html5: What is it?
Html5: What is it?
joeydehnert
A Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NETA Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NET
Harish Ranganathan
Keywords used in javascript
Keywords used in javascriptKeywords used in javascript
Keywords used in javascript
Max Friel
1.2 elements and attributes copy (3)
1.2 elements and attributes   copy (3)1.2 elements and attributes   copy (3)
1.2 elements and attributes copy (3)
Bulldogs83
Block2 Session2 Presentation
Block2 Session2 PresentationBlock2 Session2 Presentation
Block2 Session2 Presentation
Michael Gwyther
PHP Basics for Designers
PHP Basics for DesignersPHP Basics for Designers
PHP Basics for Designers
Matthew Turland
Client side rendering using mustache.js
Client side rendering using mustache.jsClient side rendering using mustache.js
Client side rendering using mustache.js
Bhashkar Sharma
Javascript
JavascriptJavascript
Javascript
Iblesoft
Creating Content With Shortcodes
Creating Content With ShortcodesCreating Content With Shortcodes
Creating Content With Shortcodes
Jon Bishop
Optimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile DevicesOptimizing Drupal for Mobile Devices
Optimizing Drupal for Mobile Devices
Sugree Phatanapherom
Joomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design PresentationJoomla Day UK 2009 Template Design Presentation
Joomla Day UK 2009 Template Design Presentation
Chris Davenport
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
Andy Wallace
HTML Semantic Elements
HTML Semantic ElementsHTML Semantic Elements
HTML Semantic Elements
Reema
Customize Your Website With HTML5 and CSS3:
Customize Your Website With HTML5 and CSS3:Customize Your Website With HTML5 and CSS3:
Customize Your Website With HTML5 and CSS3:
Reema
Html5: What is it?
Html5: What is it? Html5: What is it?
Html5: What is it?
joeydehnert

Similar to Spark View Engine (20)

Spark View Engine (Richmond)
Spark View Engine (Richmond)Spark View Engine (Richmond)
Spark View Engine (Richmond)
curtismitchell
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
olegmmiller
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
EPiServer Meetup Oslo
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
Alan Dean
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros Developer
Nyros Technologies
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
Alfresco Software
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
Ssi
SsiSsi
Ssi
Ionut Stirban
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
reybango
Jsp
JspJsp
Jsp
DSKUMAR G
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
yucefmerhi
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
John Brunswick
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
John Quaglia
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09
Pyxis Technologies
Spring and DWR
Spring and DWRSpring and DWR
Spring and DWR
wiradikusuma
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
Sagar Nakul
Spark View Engine (Richmond)
Spark View Engine (Richmond)Spark View Engine (Richmond)
Spark View Engine (Richmond)
curtismitchell
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
olegmmiller
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
Alan Dean
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros Developer
Nyros Technologies
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
reybango
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
yucefmerhi
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
John Brunswick
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09
Pyxis Technologies
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
Sagar Nakul

Recently uploaded (20)

Why Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdfWhy Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdf
anjelinajones6811
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryDataNew from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
BookNet Canada
Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
Next.js Development: The Ultimate Solution for High-Performance Web Apps
Next.js Development: The Ultimate Solution for High-Performance Web AppsNext.js Development: The Ultimate Solution for High-Performance Web Apps
Next.js Development: The Ultimate Solution for High-Performance Web Apps
rwinfotech31
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
ScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 EdinburghScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 Edinburgh
Ray Bugg
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
Top Tips to Get Your Data AI-Ready
Top Tips to Get Your Data AI-Ready   Top Tips to Get Your Data AI-Ready
Top Tips to Get Your Data AI-Ready
Precisely
Building High-Impact Teams Beyond the Product Triad.pdf
Building High-Impact Teams Beyond the Product Triad.pdfBuilding High-Impact Teams Beyond the Product Triad.pdf
Building High-Impact Teams Beyond the Product Triad.pdf
Rafael Burity
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Convert EML files to PST on Mac operating system
Convert EML files to PST on Mac operating systemConvert EML files to PST on Mac operating system
Convert EML files to PST on Mac operating system
Rachel Walker
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G坦mez Abajo
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
How Telemedicine App Development is Revolutionizing Virtual Care.pptx
How Telemedicine App Development is Revolutionizing Virtual Care.pptxHow Telemedicine App Development is Revolutionizing Virtual Care.pptx
How Telemedicine App Development is Revolutionizing Virtual Care.pptx
Dash Technologies Inc
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar
Why Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdfWhy Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdf
anjelinajones6811
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryDataNew from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
BookNet Canada
Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
Next.js Development: The Ultimate Solution for High-Performance Web Apps
Next.js Development: The Ultimate Solution for High-Performance Web AppsNext.js Development: The Ultimate Solution for High-Performance Web Apps
Next.js Development: The Ultimate Solution for High-Performance Web Apps
rwinfotech31
CIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper ColinCIOs Speak Out - A Research Series by Jasper Colin
CIOs Speak Out - A Research Series by Jasper Colin
Jasper Colin
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
ScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 EdinburghScotSecure Cyber Security Summit 2025 Edinburgh
ScotSecure Cyber Security Summit 2025 Edinburgh
Ray Bugg
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
Top Tips to Get Your Data AI-Ready
Top Tips to Get Your Data AI-Ready   Top Tips to Get Your Data AI-Ready
Top Tips to Get Your Data AI-Ready
Precisely
Building High-Impact Teams Beyond the Product Triad.pdf
Building High-Impact Teams Beyond the Product Triad.pdfBuilding High-Impact Teams Beyond the Product Triad.pdf
Building High-Impact Teams Beyond the Product Triad.pdf
Rafael Burity
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Convert EML files to PST on Mac operating system
Convert EML files to PST on Mac operating systemConvert EML files to PST on Mac operating system
Convert EML files to PST on Mac operating system
Rachel Walker
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G坦mez Abajo
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
How Telemedicine App Development is Revolutionizing Virtual Care.pptx
How Telemedicine App Development is Revolutionizing Virtual Care.pptxHow Telemedicine App Development is Revolutionizing Virtual Care.pptx
How Telemedicine App Development is Revolutionizing Virtual Care.pptx
Dash Technologies Inc
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
San Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdfSan Francisco Atlassian ACE - Mar 27 2025.pdf
San Francisco Atlassian ACE - Mar 27 2025.pdf
Matt Doar

Spark View Engine

  • 1. Ignite your ASP.NET MVC Applications with Spark View Engine t: @curtis_mitchell e: curtismitchell@gmail.com
  • 2. 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
  • 3. Who is this presentation for?
  • 4. Who is this presentation for? Web Developers... ...that use MVC, but want to switch view engines
  • 5. 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
  • 6. 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
  • 7. 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
  • 9. Agenda History of Spark Getting Started Basic Concepts Advanced Concepts Gotchas References Wrap-up
  • 10. Introducing Spark - History http://haacked.com/archive/2008/05/03/code-based-repeater-for-asp.net-mvc.aspx#67579
  • 12. Getting Started Create/Open an MVC project Reference Spark.dll and Spark.Mvc.dll Configure the view engine Start using it!
  • 14. Basic Concepts Layouts Layouts\Application.Spark Shared\Application.Spark View() method <use master=&quot;layout&quot; />
  • 15. Basic Concepts Named Content 油 <use content=&quot;&quot; /> <content name=&quot;&quot;></content>, <content:name></content:name>
  • 16. Basic Concepts Partials <use file=&quot;&quot; /> <Partial someVar=&quot;&quot; />
  • 17. Basic Concepts Variables <var [var name]=&quot;[value]&quot; type=&quot;[type]&quot; /> or def <global [var name]=&quot;[value]&quot; type=&quot;[type]&quot; /> <set [var name]=&quot;[value]&quot; /> ViewData油 <viewdata key=&quot;type&quot; />
  • 18. 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
  • 19. Basic Concepts Control-of-flow statements <test> statement, <if><else> <for> Attributes on html elements
  • 21. Advanced Concepts Inline C# Use # to delimit any plain ol' C# code
  • 22. Advanced Concepts Macros 油 Functions/Methods that take arguments and return strings
  • 23. 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
  • 24. Gotchas Intellisense not working for some types like Html (helpers) The background compiler for Spark isn't finding the assemblies Copy the assemblies local to resolve R#'s intellisense doesn't work with Spark. 油 If using R# and Spark, change R#'s intellisense setting to use Visual Studio's Don't use the <namespaces> section in the web.config file.油 Use the <using> syntax in the _global.Spark file instead.
  • 25. References and Links http://www.sparkviewengine.com http://www.whereslou.com http://www.github.com/loudej/spark http://www.dimecasts.net
  • 26. [email_address] Thank you for your time and attention! 油 油 Curtis Mitchell t: @curtis_mitchell e: curtismitchell@gmail.com b: http://www.curtismitchell.com 油 http://speakerrate.com/talks/1468 油

Editor's Notes

  • #2: Spark is a view engine that can be used with Monorail and ASP.NET MVC. We&apos;re only focusing on the functionality it brings to ASP.NET MVC. It gives you full C# capabilities within your views in a nice HTML-friendly syntax. Use it wisely!
  • #3: Spark is a view engine that can be used with Monorail and ASP.NET MVC. We&apos;re only focusing on the functionality it brings to ASP.NET MVC. It gives you full C# capabilities within your views in a nice HTML-friendly syntax. Use it wisely!
  • #4: There are reasons people web developers don&apos;t like webforms as their view engine.油 Luckily, the MVC team made it optional.
  • #5: There are reasons people web developers don&apos;t like webforms as their view engine.油 Luckily, the MVC team made it optional.
  • #7: NHaml and NVelocity are a couple of other alternative view engines.油
  • #11: Louis Dejardin of www.whereslou.com posted this comment on Phil Haack&apos;s blog, haacked.com. The blog entry was about Phil&apos;s idea of a helper method that would do essentially what the ASP.NET repeater control does. A conversation in the comments section led Lou Djardin to make this suggestion. By June 2008, a Github site was created and code was checked in for early iterations of Spark.
  • #15: First pass renders the view file and stores the output in a View &amp;quot;Named Content&amp;quot; Second pass renders the master layout and outputs the content of the view &amp;quot;Named Content&amp;quot; where specified
  • #17: On the &lt;use file=&amp;quot;&amp;quot; /&gt;, omit the extension. &lt;Partial someVar=&amp;quot;&amp;quot; /&gt; checks the local view folder and the Shared folder