I am currently starting a project utilizing ASP.NET MVC and would like to use NHaml as my view engine as I love Haml from Rails/Merb. The main issue I face is the laying out of my pages. In Webforms, I would place a ContentPlaceHolder in the head so that other pages can have specific CSS and JavaScript files.
In Rails, this is done utilizing yield and content_for
File: application.haml
%html
%head
- yield :style
File: page.haml
- content_for :style do
/ specific styles for this page
In NHaml, I can do this with partials, however any partials are global for the entire controller folder.
File: application.haml
!!!
%html{xmlns="http://www.w3.org/1999/xhtml"}
%head
_ Style
File: _Style.haml
%link{src="http://www.thescore.com/css/style.css?version=1.1" type="text/css"}
Does anyone know of a way to get NHaml to work in the Rails scenario?
Use the ^ evaluator in the master page, and set it's value in each of the layouts(content pages).
See NHaml Samples from it's source on Google Code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With