Open decebals opened 5 years ago
As information, my first design was without the menu.peb
template. The content of the menu.peb
template was added directly in base.peb
template. In this case is easy to override the headCss
and bodyJs
blocks and to add the assets that comes with menu. But I wish to extract the menu in a separate template (menu.peb
) to strip the content of base.peb
and increase the readability.
When I did this segregation I encountered this problem, I don't know how to add assets (css, scripts) to the base page, via headCss
and bodyJs
blocks, from menu.peb (that is a part/view/component of the base page).
The part with assets and how to contribute to html page head (css, javascript, ..) was discussed in https://github.com/PebbleTemplates/pebble/issues/115. The issue (#115) was closed for the reason that it is too complicated to implement (it assumes the execution of the rendering process twice - the first time for collecting information and the second time the actual rendering). I don't know how Symphony solves this type of problem but I know that in Apache Wicket you can do this from the beginning (it's a component oriented based web framework). I created this issue a long time ago and it can be closed if it gets confusing :smile: . It's not clear for me if I am a sophisticated pebble user with this component oriented approach (a component comes with the html fragment, css and javascript files) and I have too high expectations from pebble (I'm somehow only thinking about facilitating such a functionality).
I don't know if from the title is clear enough what I try to achieve, so I will explained below in details. It's more easy to follow with a concrete example. I have a template page (
base.peb
)The template of the main page (
main.peb
) extends the base template and add a menu (view/menu.peb)The content of
menu.peb
is not important for explanation but I will add it just in caseI wish a more component oriented approach. So, in the template of menu I want to come with contributions for head (
headCss
block from page) and to the end of body (bodyJs
block from page). Is it possible?They are some interesting attempts for component oriented approach like:
but I didn't find what I looking for.
Do you have other idea to how I can obtain this modularization (component oriented) in Pebble?