Support for multiple "ContentPlaceHolders"

1 view
Skip to first unread message

Simon Cropp

unread,
Nov 5, 2009, 8:18:24 PM11/5/09
to ha...@googlegroups.com
is there a feature like this in haml?

===================================
Is there a way to have something like "ContentPlaceholders" in the master
file as in aspx forms, so that I can replace for example the content in the
TitleRegion specified in the master file with content coming from the the
current view?


Possible syntax for Application.haml, using '?' not at the top-level.

%html
 %head
   %title
     ?myTitleBlock
       Default Title, In Case Concrete View Page Doesn't Override This Block
 %body
   ?myBodyBlock
     %h1= Default Header, In Case Concrete View Page Doesn't Override
This Block

Possible syntax for ConcreteView.haml, using '?' at top level
indicating to override
a named block, and not overriding another named block leaving it as the default
defined in Application.haml.

?myBodyBlock
 %h1= Overridden Header.
 %p= First paragraph of overriding text.
 %p= Second paragraph of overriding text.
 %ul
   - foreach(var obj in Model.Objects)
     %li= obj.Text
=======================================

from here http://code.google.com/p/nhaml/issues/detail?id=5

Nathan Weizenbaum

unread,
Nov 5, 2009, 9:36:05 PM11/5/09
to ha...@googlegroups.com
I'm strongly leaning towards the side of implementing this as a helper rather than as a language feature. This is for several reasons. First, I'm generally wary of adding new language features unnecessarily; Haml is already a reasonably large and complex language when you look at all of it, and I'd like to keep it from getting larger or more complex if at all possible. Second, I don't for sure about ASP.NET, but at least in Ruby I don't think this would be either difficult or ugly to implement as a helper; something like http://gist.github.com/227628. Third, Ruby Haml doesn't have any built-in notion about relationships between multiple templates, such as layouts and partials; it's strictly concerned with rendering one template at a time. That means that this probably wouldn't be implementable anyway.
Reply all
Reply to author
Forward
0 new messages