Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NHaml have a content_for ability for layouts?

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?

like image 660
Kevin Faustino Avatar asked Nov 05 '22 23:11

Kevin Faustino


1 Answers

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.

like image 165
Parsa Avatar answered Nov 15 '22 11:11

Parsa