Menu

#12 A way to specify a default value for a fragment

open
nobody
None
5
2014-08-31
2013-09-09
electrotype
No

It would be really handy to be able to specify a default value for a fragment so the fragment argument would be optional.

For example :

<%frag content>
     My default content
</%frag>

Discussion

  • Ian Robertson

    Ian Robertson - 2013-09-09

    Can you explain your use case here? I ask only because while this has often seemed like something we should add, we were never able to come up with a compelling use case to support the feature that couldn't be solved equally well using already existing features in the language.

     
  • electrotype

    electrotype - 2013-09-09

    First, I have to say that since I'm new to Jamon, and I'm only starting the view part of the framework I'm working on, I don't have concrete examples where this feature would be important.

    I'm currently trying to see what Jamon does and what it doesn't. Apart from the jamon.properties file based configurations that I'm not a big fan of (at least for now), Jamon does all what I want, and more. But I feel this "default fragment content" feature is lacking... It would really fit into Jamon. I'm sure there are ways to get around this "limitation", but Jamon would feel more complete with it, IMO.

    Also, I have tried the suggestion from Moandji Ezana of the mailing list : using the layout template from the page template itself, as a standard included template. Using composition instead of inheritence, as you said. I think I prefere this pattern to the parent-layout and page-child inheritence pattern for one main reason : there are two Renderers objects to deal with when creating the template in the controller when using inheritence. It's not as simple as a single one. I prefere to pass all the required parameters to only one makeRenderer(). It feels... better.

    That said, the limitation of this composition approach is that now the page template can not override methods from the layout template... So the more alternative ways there are to pass parameters to the layout, the better it is. For simple variables, the args are perfect. But for chunk of HTML, fragments are ideal.

    You only have to have one page template that needs to pass a fragment to the layout template, for example to replace a section on a sidebar, and then all the other pages also have to pass the fragment, even if the default section of the sidebar would be perfect on those pages.

    I'll let you know if I come across a real situation where this feature would be useful. It's probably not a show stopper missing feature, but it's one of those that you would expect/wish to be present!

     

Anonymous
Anonymous

Add attachments
Cancel